jason1i commited on
Commit
33bb1b2
1 Parent(s): 639349a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -26,6 +26,14 @@ def translate(audio):
26
  return outputs["text"]
27
 
28
 
 
 
 
 
 
 
 
 
29
  def synthesise(text):
30
  inputs = processor(text=text, return_tensors="pt")
31
  speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
 
26
  return outputs["text"]
27
 
28
 
29
+ # Added to Base to translate from Language X to any Language Y using "task": "transcribe"
30
+ # At Inference. it should use translate(sample["audio"].copy())
31
+
32
+ def translate(audio):
33
+ outputs = pipe(audio, max_new_tokens=256, generate_kwargs={"task": "transcribe", "language": "es"})
34
+ return outputs["text"]
35
+
36
+
37
  def synthesise(text):
38
  inputs = processor(text=text, return_tensors="pt")
39
  speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)