Update app.py
Browse files
app.py
CHANGED
|
@@ -81,16 +81,17 @@ def generate_image(api_key, text):
|
|
| 81 |
####
|
| 82 |
|
| 83 |
####
|
|
|
|
| 84 |
import torch
|
| 85 |
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
|
| 86 |
-
import soundfile as sf
|
| 87 |
|
| 88 |
-
|
| 89 |
-
model
|
| 90 |
-
|
|
|
|
| 91 |
|
| 92 |
# Load your local audio file
|
| 93 |
-
|
| 94 |
|
| 95 |
# Convert the audio to PyTorch tensors using the processor
|
| 96 |
inputs = processor(audio_input, sampling_rate=sampling_rate, return_tensors="pt")
|
|
@@ -104,8 +105,8 @@ generated_ids = model.generate(
|
|
| 104 |
|
| 105 |
# Decode the generated transcription
|
| 106 |
transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 107 |
-
|
| 108 |
-
###
|
| 109 |
|
| 110 |
|
| 111 |
|
|
|
|
| 81 |
####
|
| 82 |
|
| 83 |
####
|
| 84 |
+
|
| 85 |
import torch
|
| 86 |
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
|
|
|
|
| 87 |
|
| 88 |
+
|
| 89 |
+
# Load the pretrained model and processor
|
| 90 |
+
model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr")
|
| 91 |
+
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr")
|
| 92 |
|
| 93 |
# Load your local audio file
|
| 94 |
+
audio_input, sampling_rate = sf.read("/content/1001_IEO_DIS_HI.wav")
|
| 95 |
|
| 96 |
# Convert the audio to PyTorch tensors using the processor
|
| 97 |
inputs = processor(audio_input, sampling_rate=sampling_rate, return_tensors="pt")
|
|
|
|
| 105 |
|
| 106 |
# Decode the generated transcription
|
| 107 |
transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 108 |
+
|
| 109 |
+
###
|
| 110 |
|
| 111 |
|
| 112 |
|