antonin perrot-audet commited on
Commit
1a08676
1 Parent(s): 9a32f24

change asr because gradio client does not work from spaces

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -63,15 +63,17 @@ def predict(target_language, input_audio):
63
  print("-->automatic speech recognition")
64
  # split audio according to diarization
65
  song = AudioSegment.from_wav(input_audio)
66
- client = Client(SEAMLESS_API_URL, hf_token=HF_API, serialize=False)
67
  output_text = ""
68
  for turn, _, speaker in diarized.itertracks(yield_label=True):
69
  print(speaker, turn)
70
  try:
 
71
  clipped = song[turn.start * 1000 : turn.end * 1000]
72
- clipped.export(f"my.wav", format="wav", bitrate=16000)
73
 
74
- result = client.predict(f"my.wav", target_language, api_name="/asr")
 
75
 
76
  current_text = f"speaker: {speaker} text: {result} "
77
  print(current_text)
 
63
  print("-->automatic speech recognition")
64
  # split audio according to diarization
65
  song = AudioSegment.from_wav(input_audio)
66
+ # client = Client(SEAMLESS_API_URL, hf_token=HF_API, serialize=False)
67
  output_text = ""
68
  for turn, _, speaker in diarized.itertracks(yield_label=True):
69
  print(speaker, turn)
70
  try:
71
+ filename = f"{turn.start}_segment.wav"
72
  clipped = song[turn.start * 1000 : turn.end * 1000]
73
+ clipped.export(filename, format="wav", bitrate=16000)
74
 
75
+ # result = client.predict(f"my.wav", target_language, api_name="/asr")
76
+ result = automatic_speech_recognition(target_language, filename)
77
 
78
  current_text = f"speaker: {speaker} text: {result} "
79
  print(current_text)