Spaces:
Runtime error
Runtime error
| import json | |
| import streamlit as st | |
| import requests | |
| headers = {"Authorization": f"Bearer api_LbZppGQTIlpuKxWWbyNLvgPXLxXCbKYiMr"} | |
| API_URL_TTS = "https://api-inference.huggingface.co/models/espnet/kan-bayashi_ljspeech_vits" | |
| def query_audio_tts(payload): | |
| data = json.dumps(payload) | |
| response = requests.request("POST", API_URL_TTS, headers=headers, data=data) | |
| return response.content | |
| st.title('TEST TTS INFERENCE API') | |
| question = st.text_input('Enter a question') | |
| if question: | |
| with st.spinner("Generating an audio..."): | |
| audio_file = query_audio_tts({ | |
| "inputs": question, | |
| "parameters": { | |
| "vocoder_tag": "str_or_none(none)", | |
| "threshold": 0.5, | |
| "minlenratio": 0.0, | |
| "maxlenratio": 10.0, | |
| "use_att_constraint": False, | |
| "backward_window": 1, | |
| "forward_window": 3, | |
| "speed_control_alpha": 1.0, | |
| "noise_scale": 0.333, | |
| "noise_scale_dur": 0.333 | |
| } | |
| }) | |
| with open("out.flac", "wb") as f: | |
| f.write(audio_file) | |
| st.audio("out.flac") |