Spaces:
Sleeping
Sleeping
Upload myinfer_latest.py
Browse files359 unmodified lines36036136236336436536627 unmodified lines394395396397398399359 unmodified linesthread_name = threading.current_thread().nameprint(f"Thread {thread_name}: Hash {hash_val}")sample_and_print(audio_opt,thread_name)# Print the hash and thread informationif resample_sr >= 16000 and tgt_sr != resample_sr:27 unmodified linesreturn info, (None, None)def sample_and_print(array, thread_name):# Ensure the array has more than 10 elements; otherwise, use the array lengthnum_samples = 10 if len(array) > 10 else len(array)359 unmodified lines36036136236336436536627 unmodified lines394395396397398399400401402403404405406407408409410411412413414415416417418359 unmodified linesthread_name = threading.current_thread().nameprint(f"Thread {thread_name}: Hash {hash_val}")save_audio_with_thread_id(audio_opt)sample_and_print(audio_opt,thread_name)# Print the hash and thread informationif resample_sr >= 16000 and tgt_sr != resample_sr:27 unmodified linesreturn info, (None, None)def save_audio_with_thread_id(audio_opt, output_dir="output"):# Ensure the output directory existsos.makedirs(output_dir, exist_ok=True)# Get the current thread ID or namethread_id = threading.current_thread().name# Construct the filename using the thread IDfilename = f"audio_{thread_id}.wav"output_path = os.path.join(output_dir, filename)# Assuming the target sample rate is defined elsewhere; replace as necessarytgt_sr = 16000 # Example sample rate, adjust according to your needs# Write the audio filesf.write(output_path, audio_opt, tgt_sr)print(f"Saved {output_path}")def sample_and_print(array, thread_name):# Ensure the array has more than 10 elements; otherwise, use the array lengthnum_samples = 10 if len(array) > 10 else len(array)
myinfer_latest.py+20-1