I’m creating a chatbot that talks with voice using llama3.1, whisper, openvoice v2.
However, after getting the text from Lamar 3.1 to answer my question, I see an error converting it from OpenVoice v2 to voice.
OSError: [WinError 6] Handle is invalid
”’
def text_to_speech(text, reference_speaker, language=’ja’):
tone_color_converter, device, output_dir = init_openvoice()
# Extract target speaker embedding from the reference speaker
target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, vad=True)
# Use MeloTTS for base speaker text-to-speech generation
model = TTS(language=language, device=device)
speaker_ids = model.hps.data.spk2id
base_speaker_key = list(speaker_ids.keys())[0] # Use the first base speaker for simplicity
speaker_id = speaker_ids[base_speaker_key]
# Generate the base TTS audio
src_path = f'{output_dir}/tmp.wav'
model.tts_to_file(text, speaker_id, src_path, speed=1.0)
# Run tone color conversion to match the reference speaker's voice
save_path = f'{output_dir}/final_output.wav'
source_se = torch.load(f'checkpoints_v2/base_speakers/ses/{base_speaker_key}.pth', map_location=device)
tone_color_converter.convert(
audio_src_path=src_path,
src_se=source_se,
tgt_se=target_se,
output_path=save_path,
message="@MyShell"
)
”’
The error occurs in that area.
model.tts_to_file(text, speaker_id, src_path, speed=1.0)
The work environment is Windows 11, Virtual Environments vsCode…..
At first, I confirmed that gpu is not working in the virtual environment. I made gpu available again in the virtual environment because I was wondering if that was a problem. However, the same error occurred. The paths in the file were not wrong.
정희준 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1