Nag189 commited on
Commit
3818b2f
·
1 Parent(s): 583b7fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
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
- text = uploaded_file.getvalue().decode("utf-8")
65
- audio_path = text_to_speech(text)
66
- audio_file = open(audio_path, 'rb')
 
 
 
 
 
 
 
 
 
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')