Kr08 commited on
Commit
feed7c4
1 Parent(s): 37ddb1d

Update audio_processing.py

Browse files
Files changed (1) hide show
  1. audio_processing.py +3 -3
audio_processing.py CHANGED
@@ -55,7 +55,7 @@ class AudioProcessor:
55
  """Identify language of audio chunk"""
56
  lid_model, lid_processor = models['lid']
57
  inputs = lid_processor(audio_chunk, sampling_rate=16000, return_tensors="pt")
58
-
59
  with torch.no_grad():
60
  outputs = lid_model(inputs.input_values.to(self.device)).logits
61
  lang_id = torch.argmax(outputs, dim=-1)[0].item()
@@ -70,7 +70,7 @@ class AudioProcessor:
70
 
71
  mms_processor.tokenizer.set_target_lang(language)
72
  mms_model.load_adapter(language)
73
-
74
  inputs = mms_processor(audio_chunk, sampling_rate=16000, return_tensors="pt")
75
 
76
  with torch.no_grad():
@@ -87,7 +87,7 @@ class AudioProcessor:
87
 
88
  inputs = translation_tokenizer(text, return_tensors="pt")
89
  inputs = inputs.to(self.device)
90
-
91
  with torch.no_grad():
92
  outputs = translation_model.generate(
93
  **inputs,
 
55
  """Identify language of audio chunk"""
56
  lid_model, lid_processor = models['lid']
57
  inputs = lid_processor(audio_chunk, sampling_rate=16000, return_tensors="pt")
58
+ lid_model.to(self.device)
59
  with torch.no_grad():
60
  outputs = lid_model(inputs.input_values.to(self.device)).logits
61
  lang_id = torch.argmax(outputs, dim=-1)[0].item()
 
70
 
71
  mms_processor.tokenizer.set_target_lang(language)
72
  mms_model.load_adapter(language)
73
+ mms_model.to(self.device)
74
  inputs = mms_processor(audio_chunk, sampling_rate=16000, return_tensors="pt")
75
 
76
  with torch.no_grad():
 
87
 
88
  inputs = translation_tokenizer(text, return_tensors="pt")
89
  inputs = inputs.to(self.device)
90
+ translation_model.to(self.device)
91
  with torch.no_grad():
92
  outputs = translation_model.generate(
93
  **inputs,