Pijush2023 commited on
Commit
c1ad08e
·
verified ·
1 Parent(s): e87e216

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -1035,6 +1035,29 @@ def generate_audio_parler_tts(text, chunk_size=200):
1035
  logging.debug(f"Audio saved to {temp_audio_path}")
1036
  return temp_audio_path
1037
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1039
 
1040
  with gr.Row():
 
1035
  logging.debug(f"Audio saved to {temp_audio_path}")
1036
  return temp_audio_path
1037
 
1038
+
1039
+ def transcribe_function(stream, new_chunk):
1040
+ try:
1041
+ sr, y = new_chunk[0], new_chunk[1]
1042
+ except TypeError:
1043
+ print(f"Error chunk structure: {type(new_chunk)}, content: {new_chunk}")
1044
+ return stream, "", None
1045
+
1046
+ y = y.astype(np.float32) / np.max(np.abs(y))
1047
+
1048
+ if stream is not None:
1049
+ stream = np.concatenate([stream, y])
1050
+ else:
1051
+ stream = y
1052
+
1053
+ result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
1054
+
1055
+ full_text = result.get("text", "")
1056
+
1057
+ return stream, full_text, result
1058
+
1059
+
1060
+
1061
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1062
 
1063
  with gr.Row():