### Install VoiceFixer from Source Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Install the latest development version of VoiceFixer directly from its GitHub repository using pip. This is an alternative if you do not trust PyPI or want the bleeding-edge version. ```bash pip install git+https://github.com/fakerybakery/voicefixer ``` -------------------------------- ### Install FFmpeg on Windows Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Install FFmpeg on Windows using the Scoop package manager. This command ensures FFmpeg is available for processing non-WAV audio files. ```bash scoop install main/ffmpeg ``` -------------------------------- ### Install VoiceFixer 2 Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Install VoiceFixer 2 using pip. For non-WAV file support, FFmpeg must also be installed. ```bash pip install voicefixer2 ``` ```bash # macOS brew install ffmpeg # Ubuntu/Debian sudo apt install ffmpeg # Windows (scoop) scoop install main/ffmpeg ``` ```bash pip install git+https://github.com/voicefixer/voicefixer ``` -------------------------------- ### Install FFmpeg on Linux/Ubuntu Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Install FFmpeg on Linux distributions like Ubuntu using the apt package manager. FFmpeg is necessary for handling various audio formats beyond WAV. ```bash sudo apt install ffmpeg ``` -------------------------------- ### Include VoiceFixer in setup.py (PyPI) Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Add voicefixer2 to your setup.py file for installation from PyPI. This is the standard way to list package dependencies in a Python project. ```python [ 'voicefixer2', ] ``` -------------------------------- ### Install VoiceFixer2 via PyPI Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Install the latest published release of the voicefixer2 package using pip. This is the standard method for installing Python packages. ```bash pip install voicefixer2 ``` -------------------------------- ### Install FFmpeg on macOS Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Install FFmpeg on macOS using the Homebrew package manager. FFmpeg is required for non-WAV audio file support. ```bash brew install ffmpeg ``` -------------------------------- ### Include VoiceFixer in setup.py (Git URL) Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Add voicefixer2 to your setup.py file using a direct Git URL. This method is common for packages installed from version control systems. ```python [ 'voicefixer2 @ git+https://github.com/voicefixer/voicefixer', ] ``` -------------------------------- ### Include VoiceFixer2 in requirements.txt Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Add voicefixer2 to your project's requirements.txt file for easy dependency management. This ensures the correct version is installed when setting up the project. ```text voicefixer2 ``` -------------------------------- ### Get VoiceFixer CLI help Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Display the help message for the VoiceFixer command-line interface. This provides information on all available options and their usage. ```bash voicefixer -h ``` -------------------------------- ### Process all audio files in a directory using CLI Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Batch process all audio files within a specified input folder and save the results to an output folder using the VoiceFixer CLI. Ensure FFmpeg is installed for non-WAV files. ```bash voicefixer --infolder /path/to/input --outfolder /path/to/output ``` -------------------------------- ### Include VoiceFixer from Git in requirements.txt Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Specify the voicefixer package to be installed directly from its GitHub repository within your requirements.txt file. This is useful for development versions or specific forks. ```text git+https://github.com/voicefixer/voicefixer ``` -------------------------------- ### Restore Audio In-Memory with VoiceFixer Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Load an audio file, restore it in memory using VoiceFixer, and save the result. Ensure librosa and soundfile are installed for loading and saving audio. ```python import librosa import soundfile as sf from voicefixer import VoiceFixer # Load audio manually at 44100 Hz wav, _ = librosa.load("degraded_speech.wav", sr=44100) # Restore in-memory (returns np.ndarray) restored_wav = voicefixer.restore_inmem( wav_10k=wav, cuda=False, # or True for GPU mode=0 ) # Save result using soundfile sf.write("restored_output.wav", restored_wav, samplerate=44100) print(f"Restored audio shape: {restored_wav.shape}") ``` -------------------------------- ### VoiceFixer.__init__ Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Initializes the VoiceFixer restoration model, downloading weights from Hugging Face. The `model` parameter accepts any Hugging Face model repo ID containing a `vf.ckpt` checkpoint file. ```APIDOC ## VoiceFixer.__init__(model='voicefixer/voicefixer') ### Description Initialize the VoiceFixer restoration model, downloading weights from Hugging Face `VoiceFixer` is a `torch.nn.Module` that loads a pretrained speech restoration checkpoint from the Hugging Face Hub. The `model` parameter accepts any Hugging Face model repo ID that contains a `vf.ckpt` checkpoint file. On first use, the checkpoint is downloaded and cached locally via `cached_path`. The model operates at 44.1 kHz and supports 2-channel (stereo) output. ### Parameters #### Path Parameters - **model** (string) - Optional - Hugging Face model repo ID containing a `vf.ckpt` checkpoint file. Defaults to 'voicefixer/voicefixer'. ### Request Example ```python from voicefixer import VoiceFixer # Load with default pretrained model (voicefixer/voicefixer on Hugging Face) voicefixer = VoiceFixer() # Load with a custom Hugging Face model repo voicefixer_custom = VoiceFixer(model='your-org/your-voicefixer-model') # Raises RuntimeError if vf.ckpt is not found in the cache or repo ``` ``` -------------------------------- ### Command Line - Help Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Display help information for the VoiceFixer command-line interface. ```APIDOC ## voicefixer -h ### Description Displays detailed help information for the VoiceFixer command-line tool, including all available options and their descriptions. ### Usage ```bash voicefixer -h ``` ``` -------------------------------- ### Initialize VoiceFixer Model Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Initialize the VoiceFixer restoration model, optionally loading a custom model from Hugging Face. The checkpoint is downloaded and cached locally on first use. ```python from voicefixer import VoiceFixer # Load with default pretrained model (voicefixer/voicefixer on Hugging Face) voicefixer = VoiceFixer() # Load with a custom Hugging Face model repo voicefixer_custom = VoiceFixer(model='your-org/your-voicefixer-model') # Raises RuntimeError if vf.ckpt is not found in the cache or repo ``` -------------------------------- ### Python API - Initialization Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Initialize the VoiceFixer class for use in Python scripts. ```APIDOC ## VoiceFixer() ### Description Initializes the VoiceFixer object for programmatic use. ### Usage ```python from voicefixer import VoiceFixer # Initialize with default model voicefixer = VoiceFixer() # Initialize with a specific model (optional) # voicefixer = VoiceFixer(model='voicefixer/voicefixer') ``` ### Parameters #### Initialization Parameters - **model** (string) - Optional - Specifies the model to use. Defaults to the original model. Example: `'voicefixer/voicefixer'`. ``` -------------------------------- ### Initialize and Run Standalone Neural Vocoder Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Synthesize speech waveforms from mel spectrograms using the standalone `Vocoder`. It expects non-normalized mel spectrograms and supports both CPU and GPU inference. ```python import torch import librosa import numpy as np from voicefixer import Vocoder # Initialize vocoder at 44.1 kHz vocoder = Vocoder(sample_rate=44100) # Create a dummy mel spectrogram (batch=1, channels=1, time=100, mel_bins=128) mel = torch.rand(1, 1, 100, 128) # replace with real mel spectrogram # Synthesize waveform with torch.no_grad(): waveform = vocoder(mel, cuda=False) # returns [1, 1, num_samples] print(f"Output waveform shape: {waveform.shape}") # GPU inference on CUDA if torch.cuda.is_available(): waveform_gpu = vocoder(mel, cuda=True) ``` -------------------------------- ### Command Line - Process Directory Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Process all audio files within a specified directory using the VoiceFixer command-line interface. ```APIDOC ## voicefixer --infolder --outfolder ### Description Processes all audio files in a given input folder and saves them to an output folder. ### Usage ```bash voicefixer --infolder --outfolder ``` ### Parameters #### Command Line Arguments - **--infolder** (string) - Required - Path to the directory containing input audio files. - **--outfolder** (string) - Required - Path to the directory where processed audio files will be saved. ``` -------------------------------- ### Run all VoiceFixer modes via CLI Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Execute the VoiceFixer CLI with the 'all' mode to process an audio file through all available restoration modes. This is useful for comparing results across different settings. ```bash voicefixer --infile /path/to/input.wav --outfile /path/to/output.wav --mode all ``` -------------------------------- ### Command Line - Process Single File Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Process a single audio file using the VoiceFixer command-line interface. ```APIDOC ## voicefixer --infile ### Description Processes a single audio file. ### Usage ```bash voicefixer --infile ``` ### Parameters #### Command Line Arguments - **--infile** (string) - Required - Path to the input audio file (e.g., `test/utterance/original/original.wav`). - **--outfile** (string) - Optional - Path to save the processed audio file. Defaults to `outfile.wav` if not specified. - **--mode** (integer or 'all') - Optional - Specifies the processing mode. Defaults to 0. Can be an integer for specific modes or 'all' to run all modes. ``` -------------------------------- ### Initialize VoiceFixer Python API Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Instantiate the VoiceFixer class in Python to use its audio restoration capabilities programmatically. You can optionally specify a model name. ```python from voicefixer import VoiceFixer voicefixer = VoiceFixer() # or voicefixer = VoiceFixer(model='voicefixer/voicefixer') ``` -------------------------------- ### Public API - Process Audio Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Use the free public API for audio files under 5 minutes. Non-commercial use only, audio may be collected. No API key required. ```APIDOC ## POST /process_audio ### Description Processes an audio file using the VoiceFixer API. ### Method POST ### Endpoint https://voicefixer-voicefixer-api.hf.space/process_audio ### Parameters #### Request Body - **file** (multipart/form-data) - Required - The audio file to process. Can be specified using `@` notation (e.g., `file=@test.mp3`). ### Request Example ```bash curl -X POST -H "Content-Type: multipart/form-data" -F "file=@test.mp3" https://voicefixer-voicefixer-api.hf.space/process_audio > processed_audio.wav ``` ### Response #### Success Response (200) - **audio** (file) - The processed audio file in WAV format. ``` -------------------------------- ### Process a single audio file using CLI Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Use the VoiceFixer command-line interface to process a single audio file. The output will be saved to 'outfile.wav' by default if no output path is specified. ```bash voicefixer --infile test/utterance/original/original.wav ``` -------------------------------- ### Use VoiceFixer API via cURL Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md This command demonstrates how to use the VoiceFixer API for audio processing via cURL. It uploads an MP3 file and saves the processed audio to a WAV file. Ensure the API endpoint is correct. ```bash curl -X POST -H "Content-Type: multipart/form-data" -F "file=@test.mp3" https://voicefixer-voicefixer-api.hf.space/process_audio > processed_audio.wav ``` -------------------------------- ### Vocoder Initialization and Forward Pass Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Initializes the neural vocoder and synthesizes speech waveforms from mel spectrograms. ```APIDOC ## `Vocoder.__init__(sample_rate)` and `Vocoder.forward(mel, cuda=False)` ### Description Initialize and run the standalone neural vocoder on a mel spectrogram tensor. `Vocoder` is a standalone `torch.nn.Module` that synthesizes speech waveforms from 128-band mel spectrograms. It is loaded separately from `VoiceFixer` and can be used independently to convert any mel spectrogram into audio. The vocoder is pre-trained and all parameters are frozen (no gradients). It expects non-normalized mel spectrograms of shape `[batch, 1, time_steps, 128]`. ### Method `__init__`, `forward` ### Parameters #### `__init__` Parameters - **sample_rate** (int) - The sample rate for the vocoder. #### `forward` Parameters - **mel** (torch.Tensor) - The mel spectrogram tensor of shape `[batch, 1, time_steps, 128]`. - **cuda** (bool, optional) - Whether to use GPU acceleration. Defaults to False. ### Request Example ```python import torch import librosa import numpy as np from voicefixer import Vocoder # Initialize vocoder at 44.1 kHz vocoder = Vocoder(sample_rate=44100) # Create a dummy mel spectrogram (batch=1, channels=1, time=100, mel_bins=128) mel = torch.rand(1, 1, 100, 128) # replace with real mel spectrogram # Synthesize waveform with torch.no_grad(): waveform = vocoder(mel, cuda=False) # returns [1, 1, num_samples] print(f"Output waveform shape: {waveform.shape}") # Output: torch.Size([1, 1, 45056]) # GPU inference on CUDA if torch.cuda.is_available(): waveform_gpu = vocoder(mel, cuda=True) ``` ### Response - **waveform** (torch.Tensor) - The synthesized waveform tensor of shape `[batch, 1, num_samples]`. ``` -------------------------------- ### Train VoiceFixer2 with Different Modes Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Iterates through different modes (0, 1, 2) to restore audio. Specify input/output paths and GPU acceleration. Note that mode 2 might not always work on degraded speech. ```python for mode in [0,1,2]: print("Testing mode",mode) voicefixer.restore( input=os.path.join(git_root,"test/utterance/original/original.flac"), # low quality .wav/.flac file output=os.path.join(git_root,"test/utterance/output/output_mode_"+str(mode)+".flac"), # save file path cuda=False, # GPU acceleration mode=mode ) if (mode != 2): check("output_mode_" + str(mode) + ".flac") print("Pass") ``` -------------------------------- ### Restore WAV file via curl Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Use this curl command to restore a WAV file. The restored audio will be saved as a WAV file. ```bash curl -X POST \ -H "Content-Type: multipart/form-data" \ -F "file=@degraded_speech.wav" \ https://voicefixer-voicefixer-api.hf.space/process_audio \ > restored_speech.wav ``` -------------------------------- ### VoiceFixer CLI Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Command-line interface for restoring speech using VoiceFixer. ```APIDOC ## Command-Line Interface (CLI) ### Description Restore speech from the terminal using the `voicefixer` command. The CLI is installed automatically with the package as a console script entry point. It supports processing a single file or an entire folder, selecting the restoration mode, enabling GPU, and suppressing output. By default, if no output path is specified, output is saved to `outfile.wav`. ### Usage Examples ```bash # Restore a single file (default mode 0, output to outfile.wav) voicefixer --infile degraded_speech.wav # Specify output path and mode voicefixer --infile degraded_speech.wav --outfile restored.wav --mode 1 # Run all three modes (output files are suffixed with -mode0, -mode1, -mode2) voicefixer --infile degraded_speech.wav --outfile restored.wav --mode all # Process all files in a folder voicefixer --infolder /path/to/input/ --outfolder /path/to/output/ # Disable GPU acceleration explicitly voicefixer --infile degraded_speech.wav --outfile restored.wav --disable-cuda # Suppress all console output voicefixer --infile degraded_speech.wav --silent # Show help voicefixer -h ``` ``` -------------------------------- ### Python API - Processing Modes Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Explanation of the different processing modes available in the VoiceFixer Python API. ```APIDOC ### VoiceFixer Modes - **Mode 0**: Original Model (suggested by default). - **Mode 1**: Add preprocessing module (removes higher frequencies). ``` -------------------------------- ### Restore MP3 file via curl Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Use this curl command to restore an MP3 file. The processed audio will be returned as a WAV file. ```bash curl -X POST \ -H "Content-Type: multipart/form-data" \ -F "file=@test.mp3" \ https://voicefixer-voicefixer-api.hf.space/process_audio \ > processed_audio.wav ``` -------------------------------- ### VoiceFixer CLI: Restore Speech from Terminal Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Command-line interface for VoiceFixer to restore speech from audio files or folders. Supports specifying input/output paths, restoration modes, and GPU acceleration. ```bash # Restore a single file (default mode 0, output to outfile.wav) voicefixer --infile degraded_speech.wav # Specify output path and mode voicefixer --infile degraded_speech.wav --outfile restored.wav --mode 1 # Run all three modes (output files are suffixed with -mode0, -mode1, -mode2) voicefixer --infile degraded_speech.wav --outfile restored.wav --mode all # Process all files in a folder voicefixer --infolder /path/to/input/ --outfolder /path/to/output/ # Disable GPU acceleration explicitly voicefixer --infile degraded_speech.wav --outfile restored.wav --disable-cuda # Suppress all console output voicefixer --infile degraded_speech.wav --silent # Show help voicefixer -h ``` -------------------------------- ### Restore Speech Audio File Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Restore a degraded speech audio file and save the result to disk. Supports various audio formats and offers different restoration modes. GPU acceleration can be enabled. ```python import os from voicefixer import VoiceFixer voicefixer = VoiceFixer() # Mode 0: Original model — best for general use voicefixer.restore( input="degraded_speech.wav", # input: low-quality .wav or .flac output="restored_mode0.wav", # output: restored .wav file cuda=False, # set True for GPU (CUDA or MPS) mode=0 ) # Mode 1: Preprocessing removes high-frequency noise before restoration voicefixer.restore( input="noisy_recording.flac", output="restored_mode1.wav", cuda=True, # GPU acceleration (NVIDIA CUDA or Apple M1/M2 via MPS) mode=1 ) # Mode 2: Train mode — may help with severely clipped or degraded speech voicefixer.restore( input="old_recording.wav", output="restored_mode2.wav", cuda=False, mode=2 ) # Process all three modes at once (output files get -mode0, -mode1, -mode2 suffixes) for mode in [0, 1, 2]: voicefixer.restore( input="degraded_speech.wav", output=f"restored_mode{mode}.wav", cuda=False, mode=mode ) ``` -------------------------------- ### VoiceFixer.restore Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Restores a degraded speech audio file and writes the result to disk. This is the primary high-level API for file-based speech restoration. ```APIDOC ## VoiceFixer.restore(input, output, cuda=False, mode=0, your_vocoder_func=None, tqdm=tqdm) ### Description Restore a degraded speech audio file and write the result to disk This is the primary high-level API for file-based speech restoration. It loads the input audio at 44.1 kHz using librosa, processes it through the neural restoration pipeline in 30-second segments, and saves the restored audio to the output path. It supports `.wav`, `.flac`, and (with FFmpeg) `.mp3` and other formats. The `cuda` flag enables GPU acceleration on NVIDIA GPUs and Apple Silicon (MPS). A custom vocoder function can be passed via `your_vocoder_func` to replace the built-in neural vocoder. ### Parameters #### Path Parameters - **input** (string) - Required - Path to the input audio file (.wav, .flac, .mp3, etc.). - **output** (string) - Required - Path to save the restored audio file. #### Query Parameters - **cuda** (boolean) - Optional - Set to True for GPU acceleration (NVIDIA CUDA or Apple M1/M2 via MPS). Defaults to False. - **mode** (integer) - Optional - Restoration mode. 0: original model (recommended), 1: high-frequency preprocessing, 2: training mode. Defaults to 0. - **your_vocoder_func** (function) - Optional - A custom vocoder function to replace the built-in neural vocoder. - **tqdm** (object) - Optional - TQDM progress bar object. ### Request Example ```python import os from voicefixer import VoiceFixer voicefixer = VoiceFixer() # Mode 0: Original model — best for general use voicefixer.restore( input="degraded_speech.wav", # input: low-quality .wav or .flac output="restored_mode0.wav", # output: restored .wav file cuda=False, # set True for GPU (CUDA or MPS) mode=0 ) # Mode 1: Preprocessing removes high-frequency noise before restoration voicefixer.restore( input="noisy_recording.flac", output="restored_mode1.wav", cuda=True, # GPU acceleration (NVIDIA CUDA or Apple M1/M2 via MPS) mode=1 ) # Mode 2: Train mode — may help with severely clipped or degraded speech voicefixer.restore( input="old_recording.wav", output="restored_mode2.wav", cuda=False, mode=2 ) # Process all three modes at once (output files get -mode0, -mode1, -mode2 suffixes) for mode in [0, 1, 2]: voicefixer.restore( input="degraded_speech.wav", output=f"restored_mode{mode}.wav", cuda=False, mode=mode ) ``` ``` -------------------------------- ### VoiceFixer.restore_inmem Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Restores speech from an in-memory numpy waveform array, returning a numpy array without touching the filesystem. This is a lower-level API useful for integrating into audio processing pipelines. ```APIDOC ## VoiceFixer.restore_inmem(wav_10k, cuda=False, mode=0, your_vocoder_func=None, tqdm=tqdm) ### Description Restore speech from an in-memory numpy waveform array, returning a numpy array This lower-level API accepts a pre-loaded numpy waveform (resampled to 44.1 kHz) and returns a restored numpy array without touching the filesystem. It is useful when integrating VoiceFixer into audio processing pipelines (e.g., with pydub, soundfile, or torchaudio). Audio is processed in 30-second chunks with automatic frame alignment and energy normalization. ### Parameters #### Path Parameters - **wav_10k** (numpy.ndarray) - Required - Pre-loaded numpy waveform array (resampled to 44.1 kHz). #### Query Parameters - **cuda** (boolean) - Optional - Set to True for GPU acceleration (NVIDIA CUDA or Apple M1/M2 via MPS). Defaults to False. - **mode** (integer) - Optional - Restoration mode. 0: original model (recommended), 1: high-frequency preprocessing, 2: training mode. Defaults to 0. - **your_vocoder_func** (function) - Optional - A custom vocoder function to replace the built-in neural vocoder. - **tqdm** (object) - Optional - TQDM progress bar object. ### Request Example ```python import librosa import soundfile as sf from voicefixer import VoiceFixer voicefixer = VoiceFixer() # Example usage (assuming you have a degraded audio file loaded as a numpy array) # degraded_audio_path = "degraded_speech.wav" # wav_10k, sr = librosa.load(degraded_audio_path, sr=44100) # restored_wav = voicefixer.restore_inmem(wav_10k, cuda=False, mode=0) # To save the restored audio to a file: # sf.write("restored_inmem.wav", restored_wav, sr) ``` ``` -------------------------------- ### Vocoder Oracle Test: Reconstruct Audio from Mel Spectrogram Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Use the `Vocoder.oracle` method to test vocoder quality by reconstructing audio from a clean reference file's mel spectrogram. This establishes an upper bound on vocoder fidelity. ```python from voicefixer import Vocoder vocoder = Vocoder(sample_rate=44100) # Reconstruct from oracle mel spectrogram (reads input, synthesizes, saves output) vocoder.oracle( fpath="clean_reference.flac", out_path="oracle_reconstruction.flac", cuda=False ) # With GPU acceleration vocoder.oracle( fpath="clean_reference.flac", out_path="oracle_reconstruction_gpu.flac", cuda=True ) ``` -------------------------------- ### Vocoder Oracle Test Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Reconstructs audio from a clean waveform via ground-truth mel spectrogram for vocoder quality testing. ```APIDOC ## `Vocoder.oracle(fpath, out_path, cuda=False)` ### Description Reconstruct audio from a clean waveform via ground-truth mel spectrogram (vocoder oracle test). This method reads a clean reference audio file, computes its mel spectrogram using librosa, feeds it through the neural vocoder, and saves the result. It is primarily used for testing vocoder quality without the upstream restoration model, establishing an upper-bound on vocoder fidelity. ### Method `oracle` ### Parameters - **fpath** (str) - Path to the input clean audio file. - **out_path** (str) - Path to save the reconstructed audio file. - **cuda** (bool, optional) - Whether to use GPU acceleration. Defaults to False. ### Request Example ```python from voicefixer import Vocoder vocoder = Vocoder(sample_rate=44100) # Reconstruct from oracle mel spectrogram (reads input, synthesizes, saves output) vocoder.oracle( fpath="clean_reference.flac", out_path="oracle_reconstruction.flac", cuda=False ) # With GPU acceleration vocoder.oracle( fpath="clean_reference.flac", out_path="oracle_reconstruction_gpu.flac", cuda=True ) ``` ``` -------------------------------- ### Restore Speech In-Memory Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Restore speech from an in-memory numpy waveform array and return a numpy array. This is useful for integrating into audio processing pipelines. ```python import librosa import soundfile as sf from voicefixer import VoiceFixer voicefixer = VoiceFixer() ``` -------------------------------- ### Change VoiceFixer mode via CLI Source: https://github.com/render-ai-team/voicefixer2/blob/main/README.md Specify a processing mode (e.g., mode 1 for preprocessing) when using the VoiceFixer CLI. The default mode is 0. This allows for different audio restoration strategies. ```bash voicefixer --infile /path/to/input.wav --outfile /path/to/output.wav --mode 1 ``` -------------------------------- ### Remove Higher Frequency Content with VoiceFixer Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Use VoiceFixer's `remove_higher_frequency` utility to filter out high-frequency noise from an audio waveform. This can be used as a standalone pre-filter. ```python import librosa import soundfile as sf from voicefixer import VoiceFixer voicefixer = VoiceFixer() # Load raw waveform wav, _ = librosa.load("high_freq_noise.wav", sr=44100) # Remove frequencies above 95% energy threshold filtered_wav = voicefixer.remove_higher_frequency(wav, ratio=0.95) # Save filtered audio sf.write("filtered_output.wav", filtered_wav, samplerate=44100) print(f"Original length: {len(wav)}, Filtered length: {len(filtered_wav)}") ``` -------------------------------- ### VoiceFixer.remove_higher_frequency Source: https://context7.com/render-ai-team/voicefixer2/llms.txt Removes high-frequency content from a waveform via STFT-based spectral truncation. This can be used as a standalone noise reduction pre-filter. ```APIDOC ## `VoiceFixer.remove_higher_frequency(wav, ratio=0.95)` ### Description Remove high-frequency content from a waveform via STFT-based spectral truncation This preprocessing utility zeroes out frequency bins beyond the energy threshold defined by `ratio`. It is applied automatically during Mode 1 restoration on each 30-second segment. It can also be used standalone as a noise reduction pre-filter before passing audio to other tools. ### Method `remove_higher_frequency` ### Parameters - **wav** (np.ndarray) - The input waveform. - **ratio** (float, optional) - The energy threshold ratio. Defaults to 0.95. ### Request Example ```python import librosa import soundfile as sf from voicefixer import VoiceFixer voicefixer = VoiceFixer() # Load raw waveform wav, _ = librosa.load("high_freq_noise.wav", sr=44100) # Remove frequencies above 95% energy threshold filtered_wav = voicefixer.remove_higher_frequency(wav, ratio=0.95) # Save filtered audio sf.write("filtered_output.wav", filtered_wav, samplerate=44100) print(f"Original length: {len(wav)}, Filtered length: {len(filtered_wav)}") ``` ### Response - **filtered_wav** (np.ndarray) - The waveform with high-frequency content removed. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.