File size: 1,212 Bytes
8a72e8c f397e4d 8a72e8c c1eba70 8a72e8c acab20d 3f2ac30 a212e85 8a72e8c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import requests
import gradio as gr
import base64
speakers = []
with open('speakers.txt', 'r') as fp:
for line in fp:
speakers.append(line.strip())
def synthesize(key, sentence, speaker):
headers = {
'Authorization': 'Bearer {}'.format(key),
'Content-Type': 'application/json',
}
json_data = {
'text': sentence,
'speaker': speaker,
}
response = requests.post('https://rjmopratfrdjgmfmaios.functions.supabase.co/rime-tts', headers=headers, json=json_data)
audioContent = response.json()['audioContent']
decode_string = base64.b64decode(audioContent)
with open('tmp.wav', 'wb') as fp:
fp.write(decode_string)
return 'tmp.wav'
iface = gr.Interface(fn=synthesize, inputs=[gr.Textbox(type="password", info="This is where you put your Rime TTS API key."),
gr.Textbox(info="Enter the text you want synthesized here. Check out our documentation for specifics and suggestions on text input!"),
gr.Dropdown(list(speakers), info="Enter the code for the speaker you want to synthesize. (see docs/voices/)")], outputs=gr.Audio())
iface.launch() |