Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,16 +50,16 @@ def transcribe(audio_path):
|
|
| 50 |
audio_cnt, sr = librosa.load(audio_path, sr=16000)
|
| 51 |
|
| 52 |
# 将音频数据传递给 processor
|
| 53 |
-
|
| 54 |
|
| 55 |
-
print(
|
| 56 |
|
| 57 |
# 模型推理
|
| 58 |
with torch.no_grad():
|
| 59 |
-
|
| 60 |
|
| 61 |
# 解码得到转录结果
|
| 62 |
-
transcription = processor.batch_decode(
|
| 63 |
|
| 64 |
return transcription
|
| 65 |
|
|
|
|
| 50 |
audio_cnt, sr = librosa.load(audio_path, sr=16000)
|
| 51 |
|
| 52 |
# 将音频数据传递给 processor
|
| 53 |
+
input_features = processor(audio_cnt, sampling_rate=16000, return_tensors="pt").input_features
|
| 54 |
|
| 55 |
+
print(input_features)
|
| 56 |
|
| 57 |
# 模型推理
|
| 58 |
with torch.no_grad():
|
| 59 |
+
generated_ids = model.generate(input_features)
|
| 60 |
|
| 61 |
# 解码得到转录结果
|
| 62 |
+
transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 63 |
|
| 64 |
return transcription
|
| 65 |
|