Spaces:
Running
Running
SnJForever
commited on
Commit
β’
883bac9
1
Parent(s):
0a75ccd
add
Browse files
app.py
CHANGED
@@ -59,8 +59,18 @@ def on_prompt_template_change(prompt_template):
|
|
59 |
if not isinstance(prompt_template, str): return
|
60 |
return prompt_templates[prompt_template]
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
# UNCOMMENT TO USE WHISPER
|
63 |
-
def transcribe(aud_inp
|
64 |
if aud_inp is None:
|
65 |
return ""
|
66 |
text = WHISPER_MODEL.transcribe(aud_inp)
|
@@ -327,12 +337,12 @@ with gr.Blocks(css=css) as demo:
|
|
327 |
with gr.Column(scale=3):
|
328 |
btn_submit = gr.Button("Submit")
|
329 |
total_tokens_str = gr.Markdown(elem_id="total_tokens_str")
|
|
|
|
|
|
|
|
|
330 |
with gr.Row():
|
331 |
btn_clear_conversation = gr.Button("π Start New Conversation")
|
332 |
-
# with gr.Row():
|
333 |
-
# audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
|
334 |
-
# interactive=True, streaming=False)
|
335 |
-
# audio_comp.change(transcribe, inputs=[audio_comp, WHISPER_DETECT_LANG], outputs=[input_message])
|
336 |
|
337 |
|
338 |
# gr.HTML('''<br><br><br><center>You can duplicate this Space to skip the queue:<a href="https://huggingface.co/spaces/anzorq/chatgpt-demo?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a><br>
|
|
|
59 |
if not isinstance(prompt_template, str): return
|
60 |
return prompt_templates[prompt_template]
|
61 |
|
62 |
+
def lan_detector(audio_file):
|
63 |
+
print('reading the audio file')
|
64 |
+
audio = whisper.load_audio(audio_file)
|
65 |
+
audio = whisper.pad_or_trim(audio)
|
66 |
+
mel = whisper.log_mel_spectrogram(audio).to(WHISPER_MODEL.device)
|
67 |
+
_, probs = WHISPER_MODEL.detect_language(mel)
|
68 |
+
if max(probs, key=probs.get) == 'en':
|
69 |
+
return True
|
70 |
+
return False
|
71 |
+
|
72 |
# UNCOMMENT TO USE WHISPER
|
73 |
+
def transcribe(aud_inp):
|
74 |
if aud_inp is None:
|
75 |
return ""
|
76 |
text = WHISPER_MODEL.transcribe(aud_inp)
|
|
|
337 |
with gr.Column(scale=3):
|
338 |
btn_submit = gr.Button("Submit")
|
339 |
total_tokens_str = gr.Markdown(elem_id="total_tokens_str")
|
340 |
+
with gr.Row():
|
341 |
+
audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
|
342 |
+
interactive=True, streaming=False)
|
343 |
+
audio_comp.change(transcribe, inputs=[audio_comp], outputs=[input_message])
|
344 |
with gr.Row():
|
345 |
btn_clear_conversation = gr.Button("π Start New Conversation")
|
|
|
|
|
|
|
|
|
346 |
|
347 |
|
348 |
# gr.HTML('''<br><br><br><center>You can duplicate this Space to skip the queue:<a href="https://huggingface.co/spaces/anzorq/chatgpt-demo?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a><br>
|