File size: 901 Bytes
8a72e8c c1eba70 8a72e8c fe4dbe9 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 |
import requests
import gradio as gr
import base64
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 sentence you want synthesized here. Read our documentation for specifics and suggestions on text input.")], outputs=gr.Audio())
iface.launch() |