I am just installing the REST version of Microsoft Text-to-speech.
I have successfully get the the AUTH token, and can actually retrieve the voice response. (So I know that my API key/endpoints are all working). My problem is that I keep getting a 404 error when I try to retrieve the VOICES LIST.
I copied the code directly from the microsoft website (https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstart-python-get-text-to-speech-voices) as follows:
def get_voices(self):
base_url = 'https://westus.tts.speech.microsoft.com'
path = '/cognitiveservices/voices/list'
get_voices_url = base_url + path
headers = {
'Authorization': 'Bearer ' + self.access_token
}
response = requests.get(get_voices_url, headers=headers)
if response.status_code == 200:
with open('voices.json', 'wb') as voices:
voices.write(response.content)
print("\nStatus code: " + str(response.status_code) +
"\nvoices.json is ready to view.\n")
else:
print("\nStatus code: " + str(
response.status_code) + "\nSomething went wrong. Check your subscription key and headers.\n")
And, then I call it using:
if __name__ == "__main__":
subscription_key = [MY_API_KEY...this works]
app = GetVoices(subscription_key)
app.get_token()
app.get_voices()
The issue is that it returns "Status code: 404 Something went wrong. Check your subscription key and headers"
I do get a valid token (i know this because I can successfully call their save_audio() method with the same credentials and token), so that isn't the issue. I wonder if the URL's have changed? or if the documentation is out of date? doesn't seem like much else could go wrong.
(by the way, the documentation specifies using GET vs POST on this method...I have tried to both ways, with the same results).
Any ideas?