Voice Cloning
Voice manipulation functionality for fmus-vox.
This module provides functionality for voice cloning, transformation, and enhancement.
- fmus_vox.voice.clone_voice(reference_audio: str | Audio, text: str, output: str | None = None, model: str = 'yourtts', **kwargs) Audio | None[source]
Clone a voice from reference audio and synthesize text with it.
This is a simple functional API for quick voice cloning. For more control, use the VoiceCloner class directly.
- Parameters:
reference_audio – Reference audio to clone voice from (file path or Audio object)
text – Text to synthesize with the cloned voice
output – Path to save audio file (if None, returns Audio object)
model – Model to use for voice cloning (yourtts, etc.)
**kwargs – Additional model-specific parameters
- Returns:
Audio object if output is None, otherwise None
- Raises:
VoiceError – If voice cloning fails
Examples
>>> # Clone voice and play it >>> audio = clone_voice("my_voice.wav", "Hello, this is my cloned voice") >>> audio.play()
>>> # Clone voice and save to file >>> clone_voice("my_voice.wav", "Hello, this is my cloned voice", output="cloned.wav")
VoiceCloner Class
- class fmus_vox.voice.cloner.VoiceCloner(model: str = 'yourtts', **kwargs)[source]
Bases:
objectBase class for voice cloning.
This class provides the common interface for all voice cloning models and handles voice management, cloning, and synthesis.
- Parameters:
model – Name of the model to use (yourtts, etc.)
device – Computation device (cpu, cuda, auto)
**kwargs – Additional model-specific parameters
- classmethod register_model(name: str, implementation: type) None[source]
Register a model implementation.
- Parameters:
name – Model name
implementation – Model implementation class
- static __new__(cls, model: str = 'yourtts', **kwargs) VoiceCloner[source]
Create a new VoiceCloner instance of the appropriate subclass.
- Parameters:
model – Name of the model to use
**kwargs – Additional model-specific parameters
- Returns:
VoiceCloner instance
- Raises:
ModelError – If the model is not supported
- __init__(model: str = 'yourtts', device: str | None = None, **kwargs)[source]
Initialize the voice cloner.
- Parameters:
model – Name of the model to use
device – Computation device (cpu, cuda, auto)
**kwargs – Additional model-specific parameters
- add_reference(**kwargs)
- synthesize(**kwargs)
- get_voice(voice_id: str) Voice[source]
Get a voice by ID.
- Parameters:
voice_id – ID of the voice to get
- Returns:
Voice object
- Raises:
VoiceError – If voice ID is invalid