Skip to content

Instantly share code, notes, and snippets.

@zironycho
Created February 21, 2025 02:34
Show Gist options
  • Save zironycho/3707022f7d8603ea38310fa755f82b98 to your computer and use it in GitHub Desktop.
Save zironycho/3707022f7d8603ea38310fa755f82b98 to your computer and use it in GitHub Desktop.
import requests
API_TOKEN = {{your token here}}
HEADERS = {'Authorization': f'Bearer {API_TOKEN}'}
# get my actor
r = requests.get('https://typecast.ai/api/actor', headers=HEADERS)
my_actors = r.json()['result']
my_first_actor = my_actors[0]
my_first_actor_id = my_first_actor['actor_id']
# request speech synthesis
r = requests.post('https://typecast.ai/api/text-to-speech', headers=HEADERS, json={
'text': 'hello typecast',
'lang': 'auto',
'actor_id': my_first_actor_id,
'xapi_hd': True,
'model_version': 'latest'
})
with open('test.wav', 'wb') as f:
f.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment