Typhoon2-Audio is an end-to-end speech-to-speech model architecture capable of processing audio, speech, and text inputs and generating both text and speech outputs simultaneously. It is optimized specifically for Thai, but it also supports English.
1pip installpip==24.02pip installtransformers==4.45.2
3pip installfairseq==0.12.2 # fairseq required pip==24.0 to install & only worked only on python 3.104pip install flash-attn
1conversation =[2{"role":"system","content":"You are a helpful female assistant named ไต้ฝุ่น."},3{4"role":"user",5"content":[6{7"type":"audio",8"audio_url":"examples/tmp-2860cd0a094b64043226167340af03a3.wav",9},10{"type":"text","text":"Transcribe this audio"},11],12},13]14x = model.generate(15 conversation=conversation,16 max_new_tokens=500,17 do_sample=True,18 num_beams=1,19 top_p=0.9,20 repetition_penalty=1.0,21 length_penalty=1.0,22 temperature=0.7,23)24# x => x['text'] (text), x['audio'] (numpy array)25# to save the audio output26# import soundfile as sf27# sf.write("examples/speechout.wav", x["audio"]["array"], x["audio"]["sampling_rate"])
Inference - Multi turn example
python
1conversation_multi_turn =[2{3"role":"system",4"content":"You are a helpful female assistant named ไต้ฝุ่น. Respond conversationally to the speech provided in the language it is spoken in.",5},6{7"role":"user",8"content":[9{10"type":"audio",11"audio_url":"examples/tmp-2860cd0a094b64043226167340af03a3.wav",12# บอกชื่อเมืองใหญ่ๆในอเมริกามาให้หน่อยสิ -- "List some names of US cities"13},14{15"type":"text",16"text":"",17},18],19},20{21"role":"assistant",22"content":[23{24"type":"text",25"text":"โอเคค่ะ, ฉันจะบอกชื่อเมืองใหญ่ๆ ในอเมริกาให้คุณฟัง:\n\n1. นิวยอร์ก\n2. ลอสแอนเจลิส\n3. ชิคาโก\n4. ฮิวสตัน\n5. ฟิลาเดลเฟีย\n6. บอสตัน\n7. ซานฟรานซิสโก\n8. วอชิงตัน ดี.ซี. (Washington D.C.)\n9. แอตแลนต้า\n10. ซีแอตเทิล\n\nถ้าคุณต้องการข้อมูลเพิ่มเติมหรือมีคำถามอื่นๆ กรุณาถามได้เลยค่ะ'",26},27],28},29{30"role":"user",31"content":[32{33"type":"audio",34"audio_url":"examples/tmp-2284cd76e1c875525ff75327a2fc3610.wav",35# แล้วถ้าเป็นประเทศอังกฤษล่ะ -- "How about the UK"3637},38],39},40]41x = model.generate(conversation=conversation_multi_turn)42# x => x['text'] (text), x['audio'] (numpy array)43# to save the audio output44# import soundfile as sf45# sf.write("examples/speechout.wav", x["audio"]["array"], x["audio"]["sampling_rate"])
TTS functionality
python
1y = model.synthesize_speech("Hello, my name is ไต้ฝุ่น I am a language model specialized in Thai")2# y => numpy array
Evaluation Results
1) Audio and Speech Understanding
Model
ASR-en (WER↓)
ASR-th (WER↓)
En2Th (BLEU↑)
X2Th (BLEU↑)
Th2En (BLEU↑)
SALMONN-13B
5.79
98.07
0.07
0.10
14.97
DiVA-8B
30.28
65.21
9.82
5.31
7.97
Gemini-1.5-pro-001
5.98
13.56
20.69
13.52
22.54
Typhoon-Audio
8.72
14.17
17.52
10.67
24.14
Typhoon2-Audio
5.83
14.04
27.15
15.93
33.25
Model
Gender-th (Acc)
SpokenQA-th (F1)
SpeechInstruct-(en,th)
SALMONN-13B
93.26
2.95
2.47, 1.18
DiVA-8B
50.12
15.13
6.81, 2.68
Gemini-1.5-pro-001
81.32
62.10
3.24, 3.93
Typhoon-Audio
93.74
64.60
5.62, 6.11
Typhoon2-Audio
75.65
70.01
6.00, 6.79
2) Speech-to-Speech Evaluation
2.1) Content Generation
Model
SpeechIF(En)-Quality
SpeechIF(En)-Style
SpeechIF(Th)-Quality
SpeechIF(Th)-Style
Llama-Omni
5.15
5.79
1.71
2.14
GPT-4o-Audio
6.82
7.86
6.66
8.07
Typhoon2-Audio
4.92
5.39
7.19
8.04
2.2) Speech Quality
Model
SpeechIF(En)-CER
SpeechIF(En)-UTMOS
SpeechIF(Th)-CER
SpeechIF(Th)-UTMOS
Llama-Omni*
3.40
3.93
6.30
3.93
GPT-4o-Audio
3.20
3.65
8.05
3.46
Typhoon2-Audio
26.50
2.29
8.67
2.35
*Note that Llama-Omni does not generate Thai text/speech, so it has low CER and high UTMOS due to the outputs being English.
Intended Uses & Limitations
This model is experimental and may not always follow human instructions accurately, making it prone to generating hallucinations. Additionally, the model lacks moderation mechanisms and may produce harmful or inappropriate responses. Developers should carefully assess potential risks based on their specific applications.
We would like to thank the SALMONN team and the Llama-Omni team for open-sourcing their code and data, and thanks to the Biomedical and Data Lab at Mahidol University for releasing the fine-tuned Whisper that allowed us to adopt its encoder. Thanks to many other open-source projects for their useful knowledge sharing, data, code, and model weights.
If you find Typhoon2 useful for your work, please cite it using:
@misc{typhoon2,
title={Typhoon 2: A Family of Open Text and Multimodal Thai Large Language Models},
author={Kunat Pipatanakul and Potsawee Manakul and Natapong Nitarach and Warit Sirichotedumrong and Surapon Nonesung and Teetouch Jaknamon and Parinthapat Pengpun and Pittawat Taveekitworachai and Adisai Na-Thalang and Sittipong Sripaisarnmongkol and Krisanapong Jirayoot and Kasima Tharnpipitchai},
year={2024},
eprint={2412.13702},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.13702},
}