Spaces:
Runtime error
Runtime error
File size: 1,182 Bytes
e523759 4dcc177 e523759 4dcc177 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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") |