* We use a text-to-speech model to generate sentences containing words that do not appear in our dataset.
1 from transformers import WhisperProcessor , WhisperForConditionalGeneration
2 import librosa
3 # load model and processor
4 processor = WhisperProcessor . from_pretrained ( "NhutP/ViWhisper-base" )
5 model = WhisperForConditionalGeneration . from_pretrained ( "NhutP/ViWhisper-base" )
6
7 prefix_ids = model . generation_config . forced_decoder_ids
8 model . generation_config . input_ids = prefix_ids
9 model . generation_config . forced_decoder_ids = None
10
11 # load a sample
12 array , sampling_rate = librosa . load ( 'path_to_audio' , sr = 16000 ) # Load some audio sample
13 input_features = processor ( array , sampling_rate = sampling_rate , return_tensors = "pt" ) . input_features
14 # generate token ids
15 predicted_ids = model . generate ( input_features )
16 # decode token ids to text
17 transcription = processor . batch_decode ( predicted_ids , skip_special_tokens = True )
1 from transformers import pipeline
2 pipe = pipeline (
3 "automatic-speech-recognition" ,
4 model = "NhutP/ViWhisper-base" ,
5 max_new_tokens = 128 ,
6 chunk_length_s = 30 ,
7 return_timestamps = False ,
8 device = '...' # 'cpu' or 'cuda'
9 )
10 output = pipe ( path_to_audio_samplingrate_16000 ) [ 'text' ]
@misc{VSV-1100,
author = {Pham Quang Nhut and Duong Pham Hoang Anh and Nguyen Vinh Tiep},
title = {VSV-1100: Vietnamese social voice dataset},
url = {https://github.com/NhutP/VSV-1100},
year = {2024}
}
Also, please give us a star on github:
https://github.com/NhutP/ViWhisper if you find our project useful