JLW commited on
Commit
0751bd0
·
1 Parent(s): e93f3b4

Temporarily remove Whisper

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -9,8 +9,8 @@ import gradio as gr
9
  import requests
10
 
11
  # UNCOMMENT TO USE WHISPER
12
- import warnings
13
- import whisper
14
 
15
  from langchain import ConversationChain, LLMChain
16
 
@@ -58,27 +58,27 @@ POLLY_VOICE_DATA = PollyVoiceData()
58
 
59
 
60
  # UNCOMMENT TO USE WHISPER
61
- warnings.filterwarnings("ignore")
62
- WHISPER_MODEL = whisper.load_model("tiny")
63
- print("WHISPER_MODEL", WHISPER_MODEL)
64
 
65
 
66
  # UNCOMMENT TO USE WHISPER
67
- def transcribe(aud_inp):
68
- if aud_inp is None:
69
- return ""
70
- aud = whisper.load_audio(aud_inp)
71
- aud = whisper.pad_or_trim(aud)
72
- mel = whisper.log_mel_spectrogram(aud).to(WHISPER_MODEL.device)
73
- _, probs = WHISPER_MODEL.detect_language(mel)
74
- options = whisper.DecodingOptions()
75
- # options = whisper.DecodingOptions(language="ja")
76
- result = whisper.decode(WHISPER_MODEL, mel, options)
77
- print("result.text", result.text)
78
- result_text = ""
79
- if result and result.text:
80
- result_text = result.text
81
- return result_text
82
 
83
 
84
  # Pertains to Express-inator functionality
@@ -469,10 +469,10 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
469
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
470
 
471
  # UNCOMMENT TO-USE WHISPER
472
- with gr.Row():
473
- audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
474
- interactive=True, streaming=False)
475
- audio_comp.change(transcribe, inputs=[audio_comp], outputs=[message])
476
 
477
  gr.Examples(
478
  examples=["How many people live in Canada?",
 
9
  import requests
10
 
11
  # UNCOMMENT TO USE WHISPER
12
+ # import warnings
13
+ # import whisper
14
 
15
  from langchain import ConversationChain, LLMChain
16
 
 
58
 
59
 
60
  # UNCOMMENT TO USE WHISPER
61
+ # warnings.filterwarnings("ignore")
62
+ # WHISPER_MODEL = whisper.load_model("tiny")
63
+ # print("WHISPER_MODEL", WHISPER_MODEL)
64
 
65
 
66
  # UNCOMMENT TO USE WHISPER
67
+ # def transcribe(aud_inp):
68
+ # if aud_inp is None:
69
+ # return ""
70
+ # aud = whisper.load_audio(aud_inp)
71
+ # aud = whisper.pad_or_trim(aud)
72
+ # mel = whisper.log_mel_spectrogram(aud).to(WHISPER_MODEL.device)
73
+ # _, probs = WHISPER_MODEL.detect_language(mel)
74
+ # options = whisper.DecodingOptions()
75
+ # # options = whisper.DecodingOptions(language="ja")
76
+ # result = whisper.decode(WHISPER_MODEL, mel, options)
77
+ # print("result.text", result.text)
78
+ # result_text = ""
79
+ # if result and result.text:
80
+ # result_text = result.text
81
+ # return result_text
82
 
83
 
84
  # Pertains to Express-inator functionality
 
469
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
470
 
471
  # UNCOMMENT TO-USE WHISPER
472
+ # with gr.Row():
473
+ # audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
474
+ # interactive=True, streaming=False)
475
+ # audio_comp.change(transcribe, inputs=[audio_comp], outputs=[message])
476
 
477
  gr.Examples(
478
  examples=["How many people live in Canada?",