Danijel Petkovic commited on
Commit
e523759
1 Parent(s): 5008db5

First commit

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import streamlit as st
3
+ import requests
4
+
5
+ headers = {"Authorization": f"Bearer api_LbZppGQTIlpuKxWWbyNLvgPXLxXCbKYiMr"}
6
+ API_URL_TTS = "https://api-inference.huggingface.co/models/espnet/kan-bayashi_ljspeech_vits"
7
+
8
+ def query_audio_tts(payload):
9
+ data = json.dumps(payload)
10
+ response = requests.request("POST", API_URL_TTS, headers=headers, data=data)
11
+ return response.content
12
+
13
+
14
+ st.title('TEST TTS INFERENCE API')
15
+
16
+ question = st.text_input('Enter a question')
17
+
18
+ if question:
19
+
20
+ with st.spinner("Generating an audio..."):
21
+ audio_file = query_audio_tts({
22
+ "inputs": question,
23
+ "parameters": {
24
+ "vocoder_tag": "str_or_none(none)",
25
+ "threshold": 0.5,
26
+ "minlenratio": 0.0,
27
+ "maxlenratio": 10.0,
28
+ "use_att_constraint": False,
29
+ "backward_window": 1,
30
+ "forward_window": 3,
31
+ "speed_control_alpha": 1.0,
32
+ "noise_scale": 0.333,
33
+ "noise_scale_dur": 0.333
34
+ }
35
+ })
36
+
37
+ with open("out.flac", "wb") as f:
38
+ f.write(audio_file)
39
+
40
+ st.audio("out.flac")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ streamlit==1.1.0
2
+ datasets==1.11.0
3
+ requests