For anyone in the future who's gonna try this service from Azure, let me give you an easy way out. I spent a lot of time on Speaker Recognition and the official docs say something and the samples given do something else. I will use the official REST API Docs for the text-independent method.
CREATE PROFILE 👇
import http.client
import json
conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
headers = {'Ocp-Apim-Subscription-Key': 'YOUR_KEY',
'Content-type': 'application/json'}
foo = {'locale': 'en-us'}
json_data = json.dumps(foo)
conn.request(method='POST', url='/speaker/verification/v2.0/text-independent/profiles',
body=json_data, headers=headers)
response = conn.getresponse().read().decode()
conn.close()
print(response)
ENROLL PROFILE 👇
conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
headers = {'Ocp-Apim-Subscription-Key': 'YOUR_KEY'}
with open('YOUR_WAV_FILE', 'rb') as data:
conn.request(method='POST',
url=f'/speaker/verification/v2.0/text-independent/profiles/{profileId}/enrollments?ignoreMinLength=true',
body=data, headers=headers)
response = conn.getresponse().read().decode()
conn.close()
print(response)
LIST PROFILES 👇
conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
headers = {'Ocp-Apim-Subscription-Key': 'YOUR_KEY'}
conn.request(method='GET', url='/speaker/verification/v2.0/text-independent/profiles?$top=10',
headers=headers)
response = conn.getresponse().read().decode()
conn.close()
print(response)
And you can now make your own calls using this method and following the docs link I mentioned above.
Cheers and Good Luck ! 🍻