Neilblaze commited on
Commit
1b7e9bc
1 Parent(s): 96a47e3

ah now its okay

Browse files
Files changed (2) hide show
  1. app.py +4 -29
  2. requirements.txt +0 -4
app.py CHANGED
@@ -1,10 +1,6 @@
1
- from multilingual_translation import text_to_text_generation
2
- from utils import lang_ids, data_scraping
3
  import whisper
4
  import gradio as gr
5
 
6
- lang_list = list(lang_ids.keys())
7
- model_list = data_scraping()
8
  model = whisper.load_model("small")
9
 
10
  def transcribe(audio):
@@ -24,28 +20,9 @@ def transcribe(audio):
24
  # decode the audio
25
  options = whisper.DecodingOptions(fp16 = False)
26
  result = whisper.decode(model, mel, options)
27
-
28
- finalResult = text_to_text_generation(prompt=result.text, model_id='facebook/m2m100_418M', device='cpu',target_lang='English')
29
- return finalResult
30
-
31
- # api endpoint to return the transcription in EN as a json response
32
-
33
- # @app.route('/transcribe', methods=['POST'])
34
- # def transcribe_api():
35
- # if request.method == 'POST':
36
- # audio = request.files['audio']
37
- # audio = audio.read()
38
- # audio = io.BytesIO(audio)
39
- # audio = whisper.load_audio(audio)
40
- # audio = whisper.pad_or_trim(audio)
41
- # mel = whisper.log_mel_spectrogram(audio).to(model.device)
42
- # _, probs = model.detect_language(mel)
43
- # print(f"Detected language: {max(probs, key=probs.get)}")
44
- # options = whisper.DecodingOptions(fp16 = False)
45
- # result = whisper.decode(model, mel, options)
46
- # return jsonify(result)
47
-
48
-
49
 
50
 
51
 
@@ -58,6 +35,4 @@ gr.Interface(
58
  outputs=[
59
  "textbox"
60
  ],
61
- live=True).launch(debug=True, enable_queue=True)
62
-
63
- # output = gr.outputs.Textbox(label="Output Text")
 
 
 
1
  import whisper
2
  import gradio as gr
3
 
 
 
4
  model = whisper.load_model("small")
5
 
6
  def transcribe(audio):
 
20
  # decode the audio
21
  options = whisper.DecodingOptions(fp16 = False)
22
  result = whisper.decode(model, mel, options)
23
+ # translate the result to english
24
+ newresult = whisper.translate(result, "en")
25
+ return newresult.text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
 
28
 
 
35
  outputs=[
36
  "textbox"
37
  ],
38
+ live=True).launch()
 
 
requirements.txt CHANGED
@@ -1,6 +1,2 @@
1
- torch
2
- beautifulsoup4==4.11.2
3
- multilingual_translation==0.0.5
4
- requests==2.28.1
5
  tensorflow
6
  git+https://github.com/openai/whisper.git
 
 
 
 
 
1
  tensorflow
2
  git+https://github.com/openai/whisper.git