1
0
Fork 0

first commit

This commit is contained in:
Charles95 2024-10-11 02:55:07 +00:00
commit e8f9795aa3
10 changed files with 256 additions and 0 deletions

34
.gitattributes vendored Normal file
View File

@ -0,0 +1,34 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text

71
README.md Normal file
View File

@ -0,0 +1,71 @@
---
license: mit
tags:
- audio
- automatic-speech-recognition
datasets:
- librispeech_asr
---
# SpeechT5 (ASR task)
SpeechT5 model fine-tuned for automatic speech recognition (speech-to-text) on LibriSpeech.
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.
SpeechT5 was first released in [this repository](https://github.com/microsoft/SpeechT5/), [original weights](https://huggingface.co/ajyy/SpeechT5/). The license used is [MIT](https://github.com/microsoft/SpeechT5/blob/main/LICENSE).
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.
## Model Description
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.
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.
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.
## Intended Uses & Limitations
You can use this model for automatic speech recognition. See the [model hub](https://huggingface.co/models?search=speecht5) to look for fine-tuned versions on a task that interests you.
Currently, both the feature extractor and model support PyTorch.
## Citation
**BibTeX:**
```bibtex
@inproceedings{ao-etal-2022-speecht5,
title = {{S}peech{T}5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing},
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},
booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
month = {May},
year = {2022},
pages={5723--5738},
}
```
## How to Get Started With the Model
Use the code below to convert a mono 16 kHz speech waveform to text.
```python
from transformers import SpeechT5Processor, SpeechT5ForSpeechToText
from datasets import load_dataset
dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
dataset = dataset.sort("id")
sampling_rate = dataset.features["audio"].sampling_rate
example_speech = dataset[0]["audio"]["array"]
processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_asr")
model = SpeechT5ForSpeechToText.from_pretrained("microsoft/speecht5_asr")
inputs = processor(audio=example_speech, sampling_rate=sampling_rate, return_tensors="pt")
predicted_ids = model.generate(**inputs, max_length=100)
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
print(transcription[0])
```

4
added_tokens.json Normal file
View File

@ -0,0 +1,4 @@
{
"<ctc_blank>": 80,
"<mask>": 79
}

91
config.json Normal file
View File

@ -0,0 +1,91 @@
{
"activation_dropout": 0.1,
"apply_spec_augment": true,
"architectures": [
"SpeechT5ForSpeechToText"
],
"attention_dropout": 0.1,
"bos_token_id": 0,
"conv_bias": false,
"conv_dim": [
512,
512,
512,
512,
512,
512,
512
],
"conv_kernel": [
10,
3,
3,
3,
3,
2,
2
],
"conv_stride": [
5,
2,
2,
2,
2,
2,
2
],
"decoder_attention_heads": 12,
"decoder_ffn_dim": 3072,
"decoder_layerdrop": 0.1,
"decoder_layers": 6,
"decoder_start_token_id": 2,
"encoder_attention_heads": 12,
"encoder_ffn_dim": 3072,
"encoder_layerdrop": 0.1,
"encoder_layers": 12,
"encoder_max_relative_position": 160,
"eos_token_id": 2,
"feat_extract_activation": "gelu",
"feat_extract_norm": "group",
"feat_proj_dropout": 0.0,
"guided_attention_loss_num_heads": 2,
"guided_attention_loss_scale": 10.0,
"guided_attention_loss_sigma": 0.4,
"hidden_act": "gelu",
"hidden_dropout": 0.1,
"hidden_size": 768,
"initializer_range": 0.02,
"is_encoder_decoder": true,
"layer_norm_eps": 1e-05,
"mask_feature_length": 10,
"mask_feature_min_masks": 0,
"mask_feature_prob": 0.0,
"mask_time_length": 10,
"mask_time_min_masks": 2,
"mask_time_prob": 0.05,
"max_length": 450,
"max_speech_positions": 4000,
"max_text_positions": 450,
"model_type": "speecht5",
"num_conv_pos_embedding_groups": 16,
"num_conv_pos_embeddings": 128,
"num_feat_extract_layers": 7,
"num_mel_bins": 80,
"pad_token_id": 1,
"positional_dropout": 0.1,
"reduction_factor": 2,
"scale_embedding": false,
"speaker_embedding_dim": 512,
"speech_decoder_postnet_dropout": 0.5,
"speech_decoder_postnet_kernel": 5,
"speech_decoder_postnet_layers": 5,
"speech_decoder_postnet_units": 256,
"speech_decoder_prenet_dropout": 0.5,
"speech_decoder_prenet_layers": 2,
"speech_decoder_prenet_units": 256,
"torch_dtype": "float32",
"transformers_version": "4.28.0.dev0",
"use_cache": true,
"use_guided_attention_loss": true,
"vocab_size": 81
}

9
generation_config.json Normal file
View File

@ -0,0 +1,9 @@
{
"_from_model_config": true,
"bos_token_id": 0,
"decoder_start_token_id": 2,
"eos_token_id": 2,
"max_length": 450,
"pad_token_id": 1,
"transformers_version": "4.28.0.dev0"
}

18
preprocessor_config.json Normal file
View File

@ -0,0 +1,18 @@
{
"do_normalize": false,
"feature_extractor_type": "SpeechT5FeatureExtractor",
"feature_size": 1,
"fmax": 7600,
"fmin": 80,
"frame_signal_scale": 1.0,
"hop_length": 16,
"mel_floor": 1e-10,
"num_mel_bins": 80,
"padding_side": "right",
"padding_value": 0.0,
"processor_class": "SpeechT5Processor",
"return_attention_mask": true,
"sampling_rate": 16000,
"win_function": "hann_window",
"win_length": 64
}

BIN
pytorch_model.bin (Stored with Git LFS) Normal file

Binary file not shown.

13
special_tokens_map.json Normal file
View File

@ -0,0 +1,13 @@
{
"bos_token": "<s>",
"eos_token": "</s>",
"mask_token": {
"content": "<mask>",
"lstrip": true,
"normalized": true,
"rstrip": false,
"single_word": false
},
"pad_token": "<pad>",
"unk_token": "<unk>"
}

BIN
spm_char.model (Stored with Git LFS) Normal file

Binary file not shown.

10
tokenizer_config.json Normal file
View File

@ -0,0 +1,10 @@
{
"bos_token": "<s>",
"eos_token": "</s>",
"model_max_length": 450,
"pad_token": "<pad>",
"processor_class": "SpeechT5Processor",
"sp_model_kwargs": {},
"tokenizer_class": "SpeechT5Tokenizer",
"unk_token": "<unk>"
}