How to get bdl speech vectors

#1
by ThamaluM - opened

What is the code to extract bdl speech vectors.

checkout the code here:
https://huggingface.co/spaces/Matthijs/speecht5-tts-demo/blob/main/app.py

Man I can't believe how long I looked for a male FOSS voice in text-to-speech. It's always women. They sound great but I'm a guy. Finally I don't have to talk myself anymore.

gotta download the according files from this folder:
https://huggingface.co/spaces/Matthijs/speecht5-tts-demo/tree/main/spkemb

your choice is : cmu_us_rms_arctic-wav-arctic_b0353.npy
I found the other male voice better sounding in the result.

import numpy as np

from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
import torch
import soundfile as sf

processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts")
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")

speaker_embedding = np.load("/home/knut/Downloads/cmu_us_bdl_arctic-wav-arctic_a0009.npy")
speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)

inputs = processor(text="A Cognitive Architecture for Machine Consciousness and Artificial Superintelligence: Updating Working Memory Iteratively", return_tensors="pt")
input_ids = inputs["input_ids"]
input_ids = input_ids[..., :model.config.max_text_positions]

speech = model.generate_speech(inputs["input_ids"], speaker_embedding, vocoder=vocoder)
sf.write("speech.wav", speech.numpy(), samplerate=16000)

ThamaluM changed discussion status to closed

Sign up or log in to comment