JLW commited on
Commit
96559bd
·
1 Parent(s): e016796

Comment out Whisper functionality

Browse files
Files changed (2) hide show
  1. app.py +26 -33
  2. videos/tempfile.mp4 +2 -2
app.py CHANGED
@@ -5,8 +5,9 @@ import datetime
5
  import gradio as gr
6
  import requests
7
 
8
- import warnings
9
- import whisper
 
10
 
11
  from langchain import ConversationChain
12
 
@@ -17,35 +18,26 @@ from langchain.llms import OpenAI
17
  news_api_key = os.environ["NEWS_API_KEY"]
18
  tmdb_bearer_token = os.environ["TMDB_BEARER_TOKEN"]
19
 
20
- warnings.filterwarnings("ignore")
21
- WHISPER_MODEL = whisper.load_model("tiny")
22
- print("WHISPER_MODEL", WHISPER_MODEL)
 
23
 
24
 
25
- def transcribe(aud_inp):
26
- if aud_inp is None:
27
- return ""
28
-
29
- # load audio and pad/trim it to fit 30 seconds
30
- aud = whisper.load_audio(aud_inp)
31
- aud = whisper.pad_or_trim(aud)
32
-
33
- # make log-Mel spectrogram and move to the same device as the model
34
- mel = whisper.log_mel_spectrogram(aud).to(WHISPER_MODEL.device)
35
-
36
- # detect the spoken language
37
- _, probs = WHISPER_MODEL.detect_language(mel)
38
-
39
- # decode the audio
40
- options = whisper.DecodingOptions()
41
- result = whisper.decode(WHISPER_MODEL, mel, options)
42
-
43
- print("result.text", result.text)
44
-
45
- result_text = ""
46
- if result and result.text:
47
- result_text = result.text
48
- return result_text
49
 
50
 
51
  def load_chain():
@@ -143,10 +135,11 @@ with block:
143
  lines=1)
144
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
145
 
146
- with gr.Row():
147
- audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
148
- interactive=True, streaming=False)
149
- audio_comp.change(transcribe, inputs=[audio_comp], outputs=[message])
 
150
 
151
  gr.Examples(
152
  examples=["How many people live in Canada?",
 
5
  import gradio as gr
6
  import requests
7
 
8
+ # UNCOMMENT TO USE WHISPER
9
+ # import warnings
10
+ # import whisper
11
 
12
  from langchain import ConversationChain
13
 
 
18
  news_api_key = os.environ["NEWS_API_KEY"]
19
  tmdb_bearer_token = os.environ["TMDB_BEARER_TOKEN"]
20
 
21
+ # UNCOMMENT TO USE WHISPER
22
+ # warnings.filterwarnings("ignore")
23
+ # WHISPER_MODEL = whisper.load_model("tiny")
24
+ # print("WHISPER_MODEL", WHISPER_MODEL)
25
 
26
 
27
+ # def transcribe(aud_inp):
28
+ # if aud_inp is None:
29
+ # return ""
30
+ # aud = whisper.load_audio(aud_inp)
31
+ # aud = whisper.pad_or_trim(aud)
32
+ # mel = whisper.log_mel_spectrogram(aud).to(WHISPER_MODEL.device)
33
+ # _, probs = WHISPER_MODEL.detect_language(mel)
34
+ # options = whisper.DecodingOptions()
35
+ # result = whisper.decode(WHISPER_MODEL, mel, options)
36
+ # print("result.text", result.text)
37
+ # result_text = ""
38
+ # if result and result.text:
39
+ # result_text = result.text
40
+ # return result_text
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  def load_chain():
 
135
  lines=1)
136
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
137
 
138
+ # UNCOMMENT TO USE WHISPER
139
+ # with gr.Row():
140
+ # audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
141
+ # interactive=True, streaming=False)
142
+ # audio_comp.change(transcribe, inputs=[audio_comp], outputs=[message])
143
 
144
  gr.Examples(
145
  examples=["How many people live in Canada?",
videos/tempfile.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:faa87e7f6fe17256601a99f3b7c40ad18dc06c8e9eb366a97c1c8080b1e1a1ef
3
- size 166113
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ad6ea94ca0de42304c461a30340e259f9943ef79c9aaa68d8eef2087ee398a6
3
+ size 135190