Views
No views yet
1git clone https://github.com/ryota-komatsu/speech_resynth.git
2cd speech_resynth
3
4sudo apt install git-lfs # for UTMOS
5
6conda create -y -n py39 python=3.9.21 pip=24.0
7conda activate py39
8pip install -r requirements/requirements.txt
9
10sh scripts/setup.sh # download textlesslib and UTMOS
11
12cd src/textlesslib
13pip install -e .
14cd -1import torchaudio
2from textless.data.speech_encoder import SpeechEncoder
3
4from src.flow_matching.models import ConditionalFlowMatchingWithBigVGan
5
6wav_path = "/path/to/wav"
7
8encoder = SpeechEncoder.by_name(
9 dense_model_name="mhubert-base-vp_mls_cv_8lang",
10 quantizer_model_name="kmeans-expresso",
11 vocab_size=2000,
12 deduplicate=False,
13 need_f0=False,
14).cuda()
15
16# download a pretrained model from hugging face hub
17decoder = ConditionalFlowMatchingWithBigVGan.from_pretrained("ryota-komatsu/flow_matching_with_bigvgan").cuda()
18
19# load a waveform
20waveform, sr = torchaudio.load(wav_path)
21waveform = torchaudio.functional.resample(waveform, sr, 16000)
22
23# encode a waveform into pseudo-phonetic units
24units = encoder(waveform.cuda())["units"]
25units = units.unsqueeze(0) + 1 # 0: pad
26
27# resynthesis
28audio_values = decoder(units)