Spaces:
Runtime error
Runtime error
Update app.py (#10)
Browse files- Update app.py (7087540406264c37a0959b46b413773a7970fd35)
app.py
CHANGED
@@ -6,9 +6,9 @@ default_lang = "en"
|
|
6 |
|
7 |
# ChatGPT
|
8 |
from pyChatGPT import ChatGPT
|
9 |
-
|
10 |
-
|
11 |
-
whisper = gr.Blocks.load(name="spaces/sanchit-gandhi/whisper-large-v2")
|
12 |
import os
|
13 |
session_token = os.environ.get('SessionToken')
|
14 |
|
@@ -46,30 +46,6 @@ def chat_hf(audio, custom_token, language):
|
|
46 |
return whisper_text, gpt_response, fp.name
|
47 |
|
48 |
# whisper
|
49 |
-
#def translate(audio):
|
50 |
-
# print("""
|
51 |
-
# β
|
52 |
-
# Sending audio to Whisper ...
|
53 |
-
# β
|
54 |
-
# """)
|
55 |
-
#
|
56 |
-
# audio = whisper.load_audio(audio)
|
57 |
-
# audio = whisper.pad_or_trim(audio)
|
58 |
-
#
|
59 |
-
# mel = whisper.log_mel_spectrogram(audio).to(whisper_model.device)
|
60 |
-
#
|
61 |
-
# _, probs = whisper_model.detect_language(mel)
|
62 |
-
#
|
63 |
-
# transcript_options = whisper.DecodingOptions(task="transcribe", fp16 = False)
|
64 |
-
#
|
65 |
-
# transcription = whisper.decode(whisper_model, mel, transcript_options)
|
66 |
-
#
|
67 |
-
# print("language spoken: " + transcription.language)
|
68 |
-
# print("transcript: " + transcription.text)
|
69 |
-
# print("βββββββββββββββββββββββββββββββββββββββββββ")
|
70 |
-
#
|
71 |
-
# return transcription.text
|
72 |
-
|
73 |
def translate(audio):
|
74 |
print("""
|
75 |
β
|
@@ -77,9 +53,33 @@ def translate(audio):
|
|
77 |
β
|
78 |
""")
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
|
85 |
with gr.Blocks() as blocks:
|
|
|
6 |
|
7 |
# ChatGPT
|
8 |
from pyChatGPT import ChatGPT
|
9 |
+
import whisper
|
10 |
+
whisper_model = whisper.load_model("small")
|
11 |
+
#whisper = gr.Blocks.load(name="spaces/sanchit-gandhi/whisper-large-v2")
|
12 |
import os
|
13 |
session_token = os.environ.get('SessionToken')
|
14 |
|
|
|
46 |
return whisper_text, gpt_response, fp.name
|
47 |
|
48 |
# whisper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
def translate(audio):
|
50 |
print("""
|
51 |
β
|
|
|
53 |
β
|
54 |
""")
|
55 |
|
56 |
+
audio = whisper.load_audio(audio)
|
57 |
+
audio = whisper.pad_or_trim(audio)
|
58 |
+
|
59 |
+
mel = whisper.log_mel_spectrogram(audio).to(whisper_model.device)
|
60 |
+
|
61 |
+
_, probs = whisper_model.detect_language(mel)
|
62 |
+
|
63 |
+
transcript_options = whisper.DecodingOptions(task="transcribe", fp16 = False)
|
64 |
+
|
65 |
+
transcription = whisper.decode(whisper_model, mel, transcript_options)
|
66 |
+
|
67 |
+
print("language spoken: " + transcription.language)
|
68 |
+
print("transcript: " + transcription.text)
|
69 |
+
print("βββββββββββββββββββββββββββββββββββββββββββ")
|
70 |
+
|
71 |
+
return transcription.text
|
72 |
+
|
73 |
+
#def translate(audio):
|
74 |
+
# print("""
|
75 |
+
# β
|
76 |
+
# Sending audio to Whisper ...
|
77 |
+
# β
|
78 |
+
# """)
|
79 |
+
#
|
80 |
+
# text_result = whisper(audio, None, "transcribe", fn_index=0)
|
81 |
+
# print(text_result)
|
82 |
+
# return text_result
|
83 |
|
84 |
|
85 |
with gr.Blocks() as blocks:
|