Views
No views yet
1import soundfile as sf
2from transformers import AutoFeatureExtractor, AutoModel
3
4model_name = "yky-h/japanese-hubert-base"
5feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
6model = AutoModel.from_pretrained(model_name)
7model.eval()
8
9raw_speech_16kHz, sr = sf.read(audio_file)
10inputs = feature_extractor(
11 raw_speech_16kHz,
12 return_tensors="pt",
13 sampling_rate=sr,
14)
15outputs = model(**inputs)
16
17print(f"Input: {inputs.input_values.size()}") # [1, #samples]
18print(f"Output: {outputs.last_hidden_state.size()}") # [1, #frames, 768]1@misc{rinna-japanese-hubert-base,
2 title = {rinna/japanese-hubert-base},
3 author = {Hono, Yukiya and Mitsui, Kentaro and Sawada, Kei},
4 url = {https://huggingface.co/rinna/japanese-hubert-base}
5}
6
7@inproceedings{sawada2024release,
8 title = {Release of Pre-Trained Models for the {J}apanese Language},
9 author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
10 booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
11 month = {5},
12 year = {2024},
13 pages = {13898--13905},
14 url = {https://aclanthology.org/2024.lrec-main.1213},
15 note = {\url{https://arxiv.org/abs/2404.01657}}
16}1@article{hsu2021hubert,
2 author = {Hsu, Wei-Ning and Bolte, Benjamin and Tsai, Yao-Hung Hubert and Lakhotia, Kushal and Salakhutdinov, Ruslan and Mohamed, Abdelrahman},
3 journal = {IEEE/ACM Transactions on Audio, Speech, and Language Processing},
4 title = {HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units},
5 year = {2021},
6 volume = {29},
7 pages = {3451-3460},
8 doi = {10.1109/TASLP.2021.3122291}
9}