Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
tags:
|
4 |
+
- audio
|
5 |
+
- audio-to-audio
|
6 |
+
datasets:
|
7 |
+
- cmu-arctic
|
8 |
+
---
|
9 |
+
|
10 |
+
# SpeechT5 (voice conversion task)
|
11 |
+
|
12 |
+
SpeechT5 model fine-tuned for voice conversion (speech-to-speech) on CMU ARCTIC.
|
13 |
+
|
14 |
+
This model was introduced in [SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing](https://arxiv.org/abs/2110.07205) by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
|
15 |
+
|
16 |
+
SpeechT5 was first released in [this repository](https://github.com/microsoft/SpeechT5/), [original weights](https://huggingface.co/mechanicalsea/speecht5-vc). The license used is [MIT](https://github.com/microsoft/SpeechT5/blob/main/LICENSE).
|
17 |
+
|
18 |
+
Disclaimer: The team releasing SpeechT5 did not write a model card for this model so this model card has been written by the Hugging Face team.
|
19 |
+
|
20 |
+
## Model Description
|
21 |
+
|
22 |
+
Motivated by the success of T5 (Text-To-Text Transfer Transformer) in pre-trained natural language processing models, we propose a unified-modal SpeechT5 framework that explores the encoder-decoder pre-training for self-supervised speech/text representation learning. The SpeechT5 framework consists of a shared encoder-decoder network and six modal-specific (speech/text) pre/post-nets. After preprocessing the input speech/text through the pre-nets, the shared encoder-decoder network models the sequence-to-sequence transformation, and then the post-nets generate the output in the speech/text modality based on the output of the decoder.
|
23 |
+
|
24 |
+
Leveraging large-scale unlabeled speech and text data, we pre-train SpeechT5 to learn a unified-modal representation, hoping to improve the modeling capability for both speech and text. To align the textual and speech information into this unified semantic space, we propose a cross-modal vector quantization approach that randomly mixes up speech/text states with latent units as the interface between encoder and decoder.
|
25 |
+
|
26 |
+
Extensive evaluations show the superiority of the proposed SpeechT5 framework on a wide variety of spoken language processing tasks, including automatic speech recognition, speech synthesis, speech translation, voice conversion, speech enhancement, and speaker identification.
|
27 |
+
|
28 |
+
## Intended Uses & Limitations
|
29 |
+
|
30 |
+
You can use this model for speech conversion. See the [model hub](https://huggingface.co/models?search=speecht5) to look for fine-tuned versions on a task that interests you.
|
31 |
+
|
32 |
+
Currently, both the feature extractor and model support PyTorch.
|
33 |
+
|
34 |
+
## Citation
|
35 |
+
|
36 |
+
**BibTeX:**
|
37 |
+
|
38 |
+
```bibtex
|
39 |
+
@inproceedings{ao-etal-2022-speecht5,
|
40 |
+
title = {{S}peech{T}5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing},
|
41 |
+
author = {Ao, Junyi and Wang, Rui and Zhou, Long and Wang, Chengyi and Ren, Shuo and Wu, Yu and Liu, Shujie and Ko, Tom and Li, Qing and Zhang, Yu and Wei, Zhihua and Qian, Yao and Li, Jinyu and Wei, Furu},
|
42 |
+
booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
|
43 |
+
month = {May},
|
44 |
+
year = {2022},
|
45 |
+
pages={5723--5738},
|
46 |
+
}
|
47 |
+
```
|
48 |
+
|
49 |
+
## How to Get Started With the Model
|
50 |
+
|
51 |
+
Use the code below to convert a mono 16 kHz speech waveform into another.
|
52 |
+
|
53 |
+
```python
|
54 |
+
from transformers import SpeechT5Processor, SpeechT5ForSpeechToSpeech, SpeechT5HifiGan
|
55 |
+
from datasets import load_dataset
|
56 |
+
|
57 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
|
58 |
+
dataset = dataset.sort("id")
|
59 |
+
sampling_rate = dataset.features["audio"].sampling_rate
|
60 |
+
example_speech = dataset[0]["audio"]["array"]
|
61 |
+
|
62 |
+
processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_vc")
|
63 |
+
model = SpeechT5ForSpeechToSpeech.from_pretrained("microsoft/speecht5_vc")
|
64 |
+
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
|
65 |
+
|
66 |
+
inputs = processor(audio=example_speech, sampling_rate=sampling_rate, return_tensors="pt")
|
67 |
+
|
68 |
+
# load xvector containing speaker's voice characteristics from a file
|
69 |
+
import numpy as np
|
70 |
+
import torch
|
71 |
+
speaker_embeddings = np.load("xvector_speaker_embedding.npy")
|
72 |
+
speaker_embeddings = torch.tensor(speaker_embeddings).unsqueeze(0)
|
73 |
+
|
74 |
+
speech = model.generate_speech(inputs["input_values"], speaker_embeddings, vocoder=vocoder)
|
75 |
+
|
76 |
+
import soundfile as sf
|
77 |
+
sf.write("speech.wav", speech.numpy(), samplerate=16000)
|
78 |
+
```
|