Spaces:
Sleeping
Sleeping
Upload myinfer_latest.py
Browse files359 unmodified lines36036136236336336436536627 unmodified lines394395396397398399400401402403404405406407408409410411412413414415416417418359 unmodified lines thread_name = threading.current_thread().name print(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 information if resample_sr >= 16000 and tgt_sr != resample_sr:27 unmodified lines return info, (None, None)
def save_audio_with_thread_id(audio_opt, output_dir="output"): # Ensure the output directory exists os.makedirs(output_dir, exist_ok=True) # Get the current thread ID or name thread_id = threading.current_thread().name # Construct the filename using the thread ID filename = f"audio_{thread_id}.wav" output_path = os.path.join(output_dir, filename) # Assuming the target sample rate is defined elsewhere; replace as necessary tgt_sr = 16000 # Example sample rate, adjust according to your needs # Write the audio file sf.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 length num_samples = 10 if len(array) > 10 else len(array)myinfer_latest.py+20-1