Yusin commited on
Commit
7cc2adc
β€’
1 Parent(s): db1c851

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -31
app.py CHANGED
@@ -6,9 +6,9 @@ default_lang = "en"
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,40 +46,40 @@ 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
  # β€”
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:
 
6
 
7
  # ChatGPT
8
  from pyChatGPT import ChatGPT
9
+ #import whisper
10
+ #whisper_model = whisper.load_model("small")
11
+ whisper = gr.Interface.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
  # β€”
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
+ β€”
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: