shahpalash10 commited on
Commit
8034646
1 Parent(s): b12a91d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  from transformers import pipeline
 
3
 
4
 
5
  pipe = pipeline('translation', model='Helsinki-NLP/opus-mt-en-hi')
@@ -8,3 +9,12 @@ text = st.text_area("Enter some English text")
8
  if text:
9
  out = pipe(text, src_lang='en', tgt_lang='hi')
10
  st.json(out)
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ from gtts import gTTS
4
 
5
 
6
  pipe = pipeline('translation', model='Helsinki-NLP/opus-mt-en-hi')
 
9
  if text:
10
  out = pipe(text, src_lang='en', tgt_lang='hi')
11
  st.json(out)
12
+
13
+ translation_text = out[0]['translation_text']
14
+ tts = gTTS(translation_text, lang='hi')
15
+
16
+
17
+ tts.save("translated_audio.mp3")
18
+
19
+
20
+ st.audio("translated_audio.mp3")