unijoh commited on
Commit
0455ecb
·
verified ·
1 Parent(s): 2184cfb

Update asr.py

Browse files
Files changed (1) hide show
  1. asr.py +4 -1
asr.py CHANGED
@@ -20,12 +20,15 @@ except Exception as e:
20
  def transcribe(audio):
21
  try:
22
  if audio is None:
23
- logging.error("No audio file provided")
24
  return "ERROR: You have to either use the microphone or upload an audio file"
25
 
26
  logging.info(f"Loading audio file: {audio}")
27
  audio_samples, _ = librosa.load(audio, sr=ASR_SAMPLING_RATE, mono=True)
28
  inputs = processor(audio_samples, sampling_rate=ASR_SAMPLING_RATE, return_tensors="pt")
 
 
 
 
29
 
30
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
31
  model.to(device)
 
20
  def transcribe(audio):
21
  try:
22
  if audio is None:
 
23
  return "ERROR: You have to either use the microphone or upload an audio file"
24
 
25
  logging.info(f"Loading audio file: {audio}")
26
  audio_samples, _ = librosa.load(audio, sr=ASR_SAMPLING_RATE, mono=True)
27
  inputs = processor(audio_samples, sampling_rate=ASR_SAMPLING_RATE, return_tensors="pt")
28
+
29
+ # Set language ID for Faroese
30
+ language_id = 'fao' # ISO 639-3 code for Faroese
31
+ processor.tokenizer.set_lang(language_id)
32
 
33
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
34
  model.to(device)