Spaces:
Runtime error
Runtime error
Delete demo_with_detailed_comments.py
Browse files
demo_with_detailed_comments.py
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
from clearvoice import ClearVoice # Import the ClearVoice class for speech processing tasks
|
| 2 |
-
|
| 3 |
-
if __name__ == '__main__':
|
| 4 |
-
## ----------------- Demo One: Using a Single Model ----------------------
|
| 5 |
-
if True: # This block demonstrates how to use a single model for speech enhancement
|
| 6 |
-
# Initialize ClearVoice for the task of speech enhancement using the MossFormerGAN_SE_16K model
|
| 7 |
-
myClearVoice = ClearVoice(task='speech_enhancement', model_names=['MossFormerGAN_SE_16K'])
|
| 8 |
-
|
| 9 |
-
# 1st calling method:
|
| 10 |
-
# Process an input waveform and return the enhanced output waveform
|
| 11 |
-
# - input_path: Path to the input noisy audio file (input.wav)
|
| 12 |
-
# - The returned value is the enhanced output waveform
|
| 13 |
-
output_wav = myClearVoice(input_path='input.wav')
|
| 14 |
-
# Write the processed waveform to an output file
|
| 15 |
-
# - output_wav: The enhanced waveform data
|
| 16 |
-
# - output_path: Path to save the enhanced audio file (output.wav)
|
| 17 |
-
myClearVoice.write(output_wav, output_path='output.wav')
|
| 18 |
-
|
| 19 |
-
# 2nd calling method:
|
| 20 |
-
# Process and write audio files directly
|
| 21 |
-
# - input_path: Directory of input noisy audio files
|
| 22 |
-
# - online_write=True: Enables writing the enhanced audio directly to files during processing
|
| 23 |
-
# - output_path: Directory where the enhanced audio files will be saved
|
| 24 |
-
myClearVoice(input_path='path_to_input_wavs', online_write=True, output_path='path_to_output_wavs')
|
| 25 |
-
|
| 26 |
-
# 3rd calling method:
|
| 27 |
-
# Use an .scp file to specify input audio paths
|
| 28 |
-
# - input_path: Path to an .scp file listing multiple audio file paths
|
| 29 |
-
# - online_write=True: Directly writes the enhanced output during processing
|
| 30 |
-
# - output_path: Directory to save the enhanced output files
|
| 31 |
-
myClearVoice(input_path='data/cv_webrtc_test_set_20200521_16k.scp', online_write=True, output_path='path_to_output_waves')
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
## ---------------- Demo Two: Using Multiple Models -----------------------
|
| 35 |
-
if False: # This block demonstrates using multiple models for speech enhancement
|
| 36 |
-
# Initialize ClearVoice for the task of speech enhancement using two models: FRCRN_SE_16K and MossFormerGAN_SE_16K
|
| 37 |
-
myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K', 'MossFormerGAN_SE_16K'])
|
| 38 |
-
|
| 39 |
-
# 1st calling method:
|
| 40 |
-
# Process an input waveform using the multiple models and return the enhanced output waveform
|
| 41 |
-
# - input_path: Path to the input noisy audio file (input.wav)
|
| 42 |
-
# - The returned value is the enhanced output waveform after being processed by the models
|
| 43 |
-
output_wav = myClearVoice(input_path='input.wav')
|
| 44 |
-
# Write the processed waveform to an output file
|
| 45 |
-
# - output_wav: The enhanced waveform data
|
| 46 |
-
# - output_path: Path to save the enhanced audio file (output.wav)
|
| 47 |
-
myClearVoice.write(output_wav, output_path='output.wav')
|
| 48 |
-
|
| 49 |
-
# 2nd calling method:
|
| 50 |
-
# Process and write audio files directly using multiple models
|
| 51 |
-
# - input_path: Directory of input noisy audio files
|
| 52 |
-
# - online_write=True: Enables writing the enhanced audio directly to files during processing
|
| 53 |
-
# - output_path: Directory where the enhanced audio files will be saved
|
| 54 |
-
myClearVoice(input_path='path_to_input_wavs', online_write=True, output_path='path_to_output_wavs')
|
| 55 |
-
|
| 56 |
-
# 3rd calling method:
|
| 57 |
-
# Use an .scp file to specify input audio paths for multiple models
|
| 58 |
-
# - input_path: Path to an .scp file listing multiple audio file paths
|
| 59 |
-
# - online_write=True: Directly writes the enhanced output during processing
|
| 60 |
-
# - output_path: Directory to save the enhanced output files
|
| 61 |
-
myClearVoice(input_path='data/cv_webrtc_test_set_20200521_16k.scp', online_write=True, output_path='path_to_output_waves')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|