unijoh commited on
Commit
280dcb1
·
verified ·
1 Parent(s): bea3b6c

Update asr.py

Browse files
Files changed (1) hide show
  1. asr.py +3 -3
asr.py CHANGED
@@ -1,5 +1,5 @@
1
  import librosa
2
- from transformers import pipeline, Wav2Vec2Processor, Wav2Vec2ForCTC
3
  import logging
4
 
5
  # Set up logging
@@ -10,7 +10,7 @@ MODEL_ID = "facebook/mms-1b-all"
10
 
11
  try:
12
  # Create the pipeline with the appropriate model
13
- pipe = pipeline("automatic-speech-recognition", model=MODEL_ID)
14
  logging.info("ASR pipeline loaded successfully.")
15
  except Exception as e:
16
  logging.error(f"Error loading ASR pipeline: {e}")
@@ -35,7 +35,7 @@ def transcribe(audio):
35
 
36
  # Process the audio with the pipeline
37
  try:
38
- transcription = pipe(audio_samples, return_tensors="pt", language="fao")["text"]
39
  except Exception as e:
40
  logging.error(f"Error during transcription with pipeline: {e}")
41
  return f"ERROR: Transcription failed - {e}"
 
1
  import librosa
2
+ from transformers import pipeline
3
  import logging
4
 
5
  # Set up logging
 
10
 
11
  try:
12
  # Create the pipeline with the appropriate model
13
+ pipe = pipeline("automatic-speech-recognition", model=MODEL_ID, tokenizer=MODEL_ID)
14
  logging.info("ASR pipeline loaded successfully.")
15
  except Exception as e:
16
  logging.error(f"Error loading ASR pipeline: {e}")
 
35
 
36
  # Process the audio with the pipeline
37
  try:
38
+ transcription = pipe(audio_samples, chunk_length_s=10, stride_length_s=5)["text"]
39
  except Exception as e:
40
  logging.error(f"Error during transcription with pipeline: {e}")
41
  return f"ERROR: Transcription failed - {e}"