The steps for this recipe are as follows:
- Import the libraries:
import requests
from playsound import playsound
- Set the variables. These are the keys and variables that we retrieved in the Getting ready section:
Endpoint_key = "you will find this in your deployment"
location = 'the location you deployed it like australiaeast'
deploymentid = 'you will find this in your deployment'
project_name = 'The name you gave to your entire project'
text = "Hey, this is a custom voice demo for Microsoft's Custom Voice"
- Generate a token:
def get_token():
fetch_token_url = f"https://{location}.api.cognitive.microsoft\
.com/sts/v1.0/issueToken"
headers = {
'Ocp-Apim-Subscription-Key': Endpoint_key
}
response = requests.post(fetch_token_url, headers=headers)
access_token = str(response.text)
return access_token
- Send a request to the custom voice with the words we want it to...