rocky963 commited on
Commit
492b879
1 Parent(s): d5a941f

feat: whisper使用开源模型

Browse files
Files changed (1) hide show
  1. main.py +12 -12
main.py CHANGED
@@ -102,22 +102,22 @@ def predict(input, history=[]):
102
  return responses, video_html, history
103
 
104
 
105
- # 通过openai whisper 语音识别
106
- # def transcribe(audio):
107
- # os.rename(audio, audio + '.wav')
108
- # audio_file = open(audio + '.wav', "rb")
109
- # transcript = openai.Audio.transcribe(
110
- # "whisper-1", audio_file, prompt="这是一段简体中文的问题。")
111
- # return transcript['text']
112
-
113
-
114
  # 通过openai whisper 语音识别
115
  def transcribe(audio):
116
  os.rename(audio, audio + '.wav')
117
  audio_file = open(audio + '.wav', "rb")
118
- transcriber = pipeline(model="openai/whisper-medium", device=0)
119
- result = transcriber(audio_file)
120
- return result['text']
 
 
 
 
 
 
 
 
 
121
 
122
 
123
  def process_audio(audio, history=[]):
 
102
  return responses, video_html, history
103
 
104
 
 
 
 
 
 
 
 
 
 
105
  # 通过openai whisper 语音识别
106
  def transcribe(audio):
107
  os.rename(audio, audio + '.wav')
108
  audio_file = open(audio + '.wav', "rb")
109
+ transcript = openai.Audio.transcribe(
110
+ "whisper-1", audio_file, prompt="这是一段简体中文的问题。")
111
+ return transcript['text']
112
+
113
+
114
+ # 通过openai whisper 语音识别
115
+ # def transcribe(audio):
116
+ # os.rename(audio, audio + '.wav')
117
+ # audio_file = open(audio + '.wav', "rb")
118
+ # transcriber = pipeline(model="openai/whisper-medium", device=0)
119
+ # result = transcriber(audio_file)
120
+ # return result['text']
121
 
122
 
123
  def process_audio(audio, history=[]):