File size: 708 Bytes
8a72e8c c1eba70 8a72e8c 9d7db96 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=["text", "text","text"], outputs=gr.Audio())
iface.launch() |