Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,17 +19,20 @@ from jiwer import cer
|
|
| 19 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor, Wav2Vec2FeatureExtractor, Wav2Vec2CTCTokenizer
|
| 20 |
|
| 21 |
|
| 22 |
-
url = "https://huggingface.co/MahtaFetrat/tempmodel/resolve/main/checkpoint-15-1200.zip"
|
| 23 |
-
output_file = wget.download(url)
|
| 24 |
|
| 25 |
# !unzip checkpoint-15-1200.zip -d extracted_model
|
| 26 |
|
| 27 |
-
zip_file = "checkpoint-15-1200.zip"
|
| 28 |
-
output_dir = "extracted_model"
|
| 29 |
|
| 30 |
-
subprocess.run(["unzip", zip_file, "-d", output_dir], check=True)
|
| 31 |
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
# Function to split audio into chunks
|
| 34 |
def split_audio(audio, sampling_rate, chunk_size=30):
|
| 35 |
chunk_length = chunk_size * sampling_rate
|
|
@@ -85,7 +88,7 @@ tokenizer = Wav2Vec2CTCTokenizer("./vocab.json", unk_token="<unk>", pad_token="<
|
|
| 85 |
feature_extractor = Wav2Vec2FeatureExtractor(feature_size=1, sampling_rate=16000, padding_value=0.0, do_normalize=True, return_attention_mask=True)
|
| 86 |
processor = Wav2Vec2Processor(feature_extractor=feature_extractor, tokenizer=tokenizer)
|
| 87 |
|
| 88 |
-
latest_checkpoint =
|
| 89 |
model = Wav2Vec2ForCTC.from_pretrained(latest_checkpoint)
|
| 90 |
|
| 91 |
def tuned_wav2vec_speech_file_to_array_fn(path):
|
|
|
|
| 19 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor, Wav2Vec2FeatureExtractor, Wav2Vec2CTCTokenizer
|
| 20 |
|
| 21 |
|
| 22 |
+
# url = "https://huggingface.co/MahtaFetrat/tempmodel/resolve/main/checkpoint-15-1200.zip"
|
| 23 |
+
# output_file = wget.download(url)
|
| 24 |
|
| 25 |
# !unzip checkpoint-15-1200.zip -d extracted_model
|
| 26 |
|
| 27 |
+
# zip_file = "checkpoint-15-1200.zip"
|
| 28 |
+
# output_dir = "extracted_model"
|
| 29 |
|
| 30 |
+
# subprocess.run(["unzip", zip_file, "-d", output_dir], check=True)
|
| 31 |
|
| 32 |
|
| 33 |
+
model_name = "MahtaFetrat/wav2vec2_finetuned_on_youtube_farsi_30"
|
| 34 |
+
local_dir = snapshot_download(repo_id=model_name)
|
| 35 |
+
|
| 36 |
# Function to split audio into chunks
|
| 37 |
def split_audio(audio, sampling_rate, chunk_size=30):
|
| 38 |
chunk_length = chunk_size * sampling_rate
|
|
|
|
| 88 |
feature_extractor = Wav2Vec2FeatureExtractor(feature_size=1, sampling_rate=16000, padding_value=0.0, do_normalize=True, return_attention_mask=True)
|
| 89 |
processor = Wav2Vec2Processor(feature_extractor=feature_extractor, tokenizer=tokenizer)
|
| 90 |
|
| 91 |
+
latest_checkpoint = local_dir
|
| 92 |
model = Wav2Vec2ForCTC.from_pretrained(latest_checkpoint)
|
| 93 |
|
| 94 |
def tuned_wav2vec_speech_file_to_array_fn(path):
|