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()