Dieses Projekt arbeitet immer noch an den Fortschritten. Um Funcodec besser zu machen, teilen Sie mir bitte Ihre Bedenken mit und können Sie sie im Teil der Issues kommentieren.
egs/LibriTTS/text2speech_laura/README.md . git clone https://github.com/alibaba/FunCodec.git && cd FunCodec
pip install --editable ./? Links zum Hubface -Modell -Hub verweist das ModelsCope.
| Modellname | Modell Hub | Korpus | Bitrate | Parameter | Flops |
|---|---|---|---|---|---|
| Audio_Codec-CODEC-ZH_EN-General-16K-NQ32DS640-Pytorch | ? | Allgemein | 250 ~ 8000 | 57,83 m | 7.73g |
| Audio_Codec-CODEC-ZH_EN-General-16K-NQ32DS320-Pytorch | ? | Allgemein | 500 ~ 16000 | 14,85 m | 3,72 g |
| audio_codec-codec-en-libritts-16K-nq32ds640-pytorch | ? | Libritts | 250 ~ 8000 | 57,83 m | 7.73g |
| audio_codec-codec-en-libritts-16K-nq32ds320-pytorch | ? | Libritts | 500 ~ 16000 | 14,85 m | 3,72 g |
| audio_codec-freqCodec_magphase-en-libritts-16K-Gr8NQ32DS320-Pytorch | ? | Libritts | 500 ~ 16000 | 4,50 m | 2.18 g |
| Audio_Codec-FreqCodec_Magphase-en-Bibritts-16K-GR1NQ32DS320-Pytorch | ? | Libritts | 500 ~ 16000 | 0,52 m | 0,34 g |
Bitte beachten Sie egs/LibriTTS/codec/encoding_decoding.sh um vorgezogene Modelle herunterzuladen:
cd egs/LibriTTS/codec
model_name=audio_codec-encodec-zh_en-general-16k-nq32ds640-pytorch
bash encoding_decoding.sh --stage 0 --model_name ${model_name} --model_hub modelscope
# The pre-trained model will be downloaded to exp/audio_codec-encodec-zh_en-general-16k-nq32ds640-pytorch Bitte beachten Sie egs/LibriTTS/codec/encoding_decoding.sh um vorgezogene Modelle herunterzuladen:
cd egs/LibriTTS/codec
model_name=audio_codec-encodec-zh_en-general-16k-nq32ds640-pytorch
bash encoding_decoding.sh --stage 0 --model_name ${model_name} --model_hub huggingface
# The pre-trained model will be downloaded to exp/audio_codec-encodec-zh_en-general-16k-nq32ds640-pytorch Bitte beachten Sie egs/LibriTTS/codec/encoding_decoding.sh um Codierung und Decodierung durchzuführen. Extrahieren Sie Codes mit einem Eingabedatei input_wav.scp , und die Codes werden in einem Format von JSONL in output_dir/codecs.txt gespeichert.
cd egs/LibriTTS/codec
bash encoding_decoding.sh --stage 1 --batch_size 16 --num_workers 4 --gpu_devices " 0,1 "
--model_dir exp/ ${model_name} --bit_width 16000
--wav_scp input_wav.scp --out_dir outputs/codecs/
# input_wav.scp has the following format:
# uttid1 path/to/file1.wav
# uttid2 path/to/file2.wav
# ... Dekodieren Sie Codes mit einem Eingabedatei codecs.txt , und die rekonstruierte Wellenform wird in output_dir/logdir/output.*/*.wav .
bash encoding_decoding.sh --stage 2 --batch_size 16 --num_workers 4 --gpu_devices " 0,1 "
--model_dir exp/ ${model_name} --bit_width 16000 --file_sampling_rate 16000
--wav_scp codecs.txt --out_dir outputs/recon_wavs
# codecs.scp is the output of above encoding stage, which has the following format:
# uttid1 [[[1, 2, 3, ...],[2, 3, 4, ...], ...]]
# uttid2 [[[9, 7, 5, ...],[3, 1, 2, ...], ...]] Für häufig verwendete Open-Source-Korpora können Sie ein Modell mithilfe des Rezepts im egs -Verzeichnis trainieren. Um beispielsweise ein Modell auf dem LibriTTS Corpus zu trainieren, können Sie egs/LibriTTS/codec/run.sh verwenden:
# entry the LibriTTS recipe directory
cd egs/LibriTTS/codec
# run data downloading, preparation and training stages with 2 GPUs (device 0 and 1)
bash run.sh --stage 0 --stop_stage 3 --gpu_devices 0,1 --gpu_num 2Wir empfehlen, die Skriptbühne für die Bühne auszuführen, um einen Überblick über Funcodec zu erhalten.
Für aufgedeckte Korpora oder maßgeschneiderte Datensatz können Sie die Daten selbst vorbereiten. Im Allgemeinen verwendet Funcodec die Kaldi-ähnliche wav.scp Datei, um die Datendateien zu organisieren. wav.scp hat das folgende Format:
# for waveform files
uttid1 /path/to/uttid1.wav
uttid2 /path/to/uttid2.wav
# for kaldi-ark files
uttid3 /path/to/ark1.wav:10
uttid4 /path/to/ark1.wav:200
uttid5 /path/to/ark2.wav:10 Wie im obigen Beispiel gezeigt, unterstützt Funcodec die Kombination von Wellenformen oder Kaldi-Mark-Dateien in einer wav.scp Datei sowohl für Training als auch für Inferenz. Hier ist ein Demo -Skript, um ein Modell auf Ihrem angepassten Datensatz mit dem Namen foo zu trainieren:
cd egs/LibriTTS/codec
# 0. make the directory for train, dev and test sets
mkdir -p dump/foo/train dump/foo/dev dump/foo/test
# 1a. if you already have the wav.scp file, just place them under the corresponding directories
mv train.scp dump/foo/train/ ; mv dev.scp dump/foo/dev/ ; mv test.scp dump/foo/test/ ;
# 1b. if you don't have the wav.scp file, you can prepare it as follows
find path/to/train_set/ -iname " *.wav " | awk -F ' / ' ' {print $(NF),$0} ' | sort > dump/foo/train/wav.scp
find path/to/dev_set/ -iname " *.wav " | awk -F ' / ' ' {print $(NF),$0} ' | sort > dump/foo/dev/wav.scp
find path/to/test_set/ -iname " *.wav " | awk -F ' / ' ' {print $(NF),$0} ' | sort > dump/foo/test/wav.scp
# 2. collate shape files
mkdir exp/foo_states/train exp/foo_states/dev
torchrun --nproc_per_node=4 --master_port=1234 scripts/gen_wav_length.py --wav_scp dump/foo/train/wav.scp --out_dir exp/foo_states/train/wav_length
cat exp/foo_states/train/wav_length/wav_length. * .txt | shuf > exp/foo_states/train/speech_shape
torchrun --nproc_per_node=4 --master_port=1234 scripts/gen_wav_length.py --wav_scp dump/foo/dev/wav.scp --out_dir exp/foo_states/dev/wav_length
cat exp/foo_states/dev/wav_length/wav_length. * .txt | shuf > exp/foo_states/dev/speech_shape
# 3. train the model with 2 GPUs (device 4 and 5) on the customized dataset (foo)
bash run.sh --gpu_devices 4,5 --gpu_num 2 --dumpdir dump/foo --state_dir foo_statesDieses Projekt ist unter der MIT -Lizenz lizenziert. Funcodec enthält auch verschiedene Komponenten von Drittanbietern und einige Code, die aus anderen Repos unter anderen Open-Source-Lizenzen geändert wurden.
@misc { du2023funcodec ,
title = { FunCodec: A Fundamental, Reproducible and Integrable Open-source Toolkit for Neural Speech Codec } ,
author = { Zhihao Du, Shiliang Zhang, Kai Hu, Siqi Zheng } ,
year = { 2023 } ,
eprint = { 2309.07405 } ,
archivePrefix = { arXiv } ,
primaryClass = { cs.Sound }
}