CoolFace
Apppublic

rimeAI/rimeui

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