Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -61,8 +61,17 @@ if st.button("Convert"):
|
|
61 |
# File Uploader
|
62 |
uploaded_file = st.file_uploader("Upload your text file here", type=['txt'])
|
63 |
if uploaded_file is not None:
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
audio_bytes = audio_file.read()
|
68 |
st.audio(audio_bytes, format='audio/wav')
|
|
|
61 |
# File Uploader
|
62 |
uploaded_file = st.file_uploader("Upload your text file here", type=['txt'])
|
63 |
if uploaded_file is not None:
|
64 |
+
stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
65 |
+
#To read file as string:
|
66 |
+
text = stringio.read()
|
67 |
+
st.write(text)
|
68 |
+
|
69 |
+
st.button("Convert",key=1)
|
70 |
+
inputs = processor(text=text, return_tensors="pt")
|
71 |
+
spectrogram = model.generate_speech(inputs["input_ids"], speaker_embeddings)
|
72 |
+
with torch.no_grad():
|
73 |
+
speech = vocoder(spectrogram)
|
74 |
+
sf.write("speech.wav", speech.numpy(), samplerate=16000)
|
75 |
+
audio_file = open('speech.wav', 'rb')
|
76 |
audio_bytes = audio_file.read()
|
77 |
st.audio(audio_bytes, format='audio/wav')
|