Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,11 +14,15 @@ def transcribe_audio(audio):
|
|
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 |
# モデルによる文字起こし
|
20 |
with torch.no_grad():
|
21 |
-
predicted_ids = model.generate(input_values=
|
22 |
|
23 |
# 文字起こし結果のデコード
|
24 |
transcription = processor.decode(predicted_ids[0], skip_special_tokens=True)
|
@@ -34,4 +38,4 @@ interface = gr.Interface(
|
|
34 |
)
|
35 |
|
36 |
# インターフェースの起動
|
37 |
-
interface.launch()
|
|
|
14 |
audio_data, sampling_rate = librosa.load(audio, sr=16000)
|
15 |
|
16 |
# WhisperProcessorに渡すために、音声データを正しい形式に変換
|
17 |
+
# 返された辞書からinput_valuesを直接取得する
|
18 |
audio_input = processor(audio_data, return_tensors="pt", sampling_rate=16000)
|
19 |
|
20 |
+
# WhisperProcessorの出力にはinput_valuesが含まれるので、正しい属性にアクセス
|
21 |
+
input_values = audio_input['input_values']
|
22 |
+
|
23 |
# モデルによる文字起こし
|
24 |
with torch.no_grad():
|
25 |
+
predicted_ids = model.generate(input_values=input_values)
|
26 |
|
27 |
# 文字起こし結果のデコード
|
28 |
transcription = processor.decode(predicted_ids[0], skip_special_tokens=True)
|
|
|
38 |
)
|
39 |
|
40 |
# インターフェースの起動
|
41 |
+
interface.launch(share=True) # `share=True`で公開リンクを生成
|