S0h9l commited on
Commit
f345c14
·
1 Parent(s): a57cdfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -1,7 +1,7 @@
1
- import gradio as gr
2
- import time
3
  import whisper
4
  import cohere
 
5
  #from dotenv import load_dotenv
6
 
7
  #load_dotenv()
@@ -9,6 +9,8 @@ co = cohere.Client('0brA5yZUeNlQM98z5h4XQAiYYpCGNMbGPjk5ghE6')
9
 
10
  model = whisper.load_model("tiny")
11
 
 
 
12
  def transcribe(audio):
13
 
14
  #time.sleep(3)
@@ -41,8 +43,11 @@ def transcribe(audio):
41
  return_likelihoods='NONE')
42
  #result.text
43
  reptxt = response.generations[0].text.strip("--")
44
-
45
- return reptxt
 
 
 
46
 
47
 
48
 
@@ -50,7 +55,8 @@ gr.Interface(
50
  title = 'OpenAI Whisper ASR Gradio Web UI',
51
  fn=transcribe,
52
  inputs=[
53
- gr.inputs.Audio(source="microphone", type="filepath")
 
54
  ],
55
  outputs=[
56
  "textbox"
 
1
+ import gradio as gr
 
2
  import whisper
3
  import cohere
4
+ from gtts import gTTS
5
  #from dotenv import load_dotenv
6
 
7
  #load_dotenv()
 
9
 
10
  model = whisper.load_model("tiny")
11
 
12
+ LANGUAGES = list(gtts.lang.tts_langs())
13
+
14
  def transcribe(audio):
15
 
16
  #time.sleep(3)
 
43
  return_likelihoods='NONE')
44
  #result.text
45
  reptxt = response.generations[0].text.strip("--")
46
+
47
+ tts = gTTS(text=text, lang='el')
48
+ tts.save('result.mp3')
49
+ filename = 'result.mp3'
50
+ return filename
51
 
52
 
53
 
 
55
  title = 'OpenAI Whisper ASR Gradio Web UI',
56
  fn=transcribe,
57
  inputs=[
58
+ gr.inputs.Audio(source="microphone", type="filepath"),
59
+ gr.Radio(label="Language", choices=LANGUAGES, value="en")
60
  ],
61
  outputs=[
62
  "textbox"