soiz commited on
Commit
8ff5286
·
verified ·
1 Parent(s): 1a83c9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -14,21 +14,14 @@ def transcribe_audio(audio):
14
  audio_data, sampling_rate = librosa.load(audio, sr=16000)
15
 
16
  # WhisperProcessorに渡すために、音声データを正しい形式に変換
17
- # 返された辞書を表示して出力形式を確認
18
  audio_input = processor(audio_data, return_tensors="pt", sampling_rate=16000)
19
-
20
- # 出力形式を確認
21
- print(audio_input) # デバッグ: 出力形式を確認
22
-
23
- # input_values ではなく、input_features を使用する場合もある
24
- input_values = audio_input.get('input_values') or audio_input.get('input_features')
25
 
26
- if input_values is None:
27
- raise ValueError("音声データが適切に処理されていないか、必要なキーが見つかりませんでした")
28
 
29
  # モデルによる文字起こし
30
  with torch.no_grad():
31
- predicted_ids = model.generate(input_values=input_values)
32
 
33
  # 文字起こし結果のデコード
34
  transcription = processor.decode(predicted_ids[0], skip_special_tokens=True)
@@ -44,4 +37,4 @@ interface = gr.Interface(
44
  )
45
 
46
  # インターフェースの起動
47
- interface.launch(share=True) # `share=True`で公開リンクを生成
 
14
  audio_data, sampling_rate = librosa.load(audio, sr=16000)
15
 
16
  # WhisperProcessorに渡すために、音声データを正しい形式に変換
 
17
  audio_input = processor(audio_data, return_tensors="pt", sampling_rate=16000)
 
 
 
 
 
 
18
 
19
+ # input_features を取得
20
+ input_features = audio_input["input_features"]
21
 
22
  # モデルによる文字起こし
23
  with torch.no_grad():
24
+ predicted_ids = model.generate(input_features=input_features)
25
 
26
  # 文字起こし結果のデコード
27
  transcription = processor.decode(predicted_ids[0], skip_special_tokens=True)
 
37
  )
38
 
39
  # インターフェースの起動
40
+ interface.launch(share=True)