PATTARA TIPAKSORN
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -18,7 +18,28 @@ More information needed
|
|
18 |
More information needed
|
19 |
|
20 |
## Quickstart
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
## Evaluation Performance
|
24 |
Note: WER calculated with newmm tokenizer for Thai segmentation.
|
|
|
18 |
More information needed
|
19 |
|
20 |
## Quickstart
|
21 |
+
You can transcribe audio files using the [`pipeline`](https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline) class with the following code snippet:
|
22 |
+
```python
|
23 |
+
import torch
|
24 |
+
from transformers import pipeline
|
25 |
+
|
26 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
27 |
+
torch_dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
|
28 |
+
|
29 |
+
lang = "th"
|
30 |
+
task = "transcribe"
|
31 |
+
|
32 |
+
pipe = pipeline(
|
33 |
+
task="automatic-speech-recognition",
|
34 |
+
model="nectec/Pathumma-whisper-th-large-v3",
|
35 |
+
torch_dtype=torch_dtype,
|
36 |
+
device=device,
|
37 |
+
)
|
38 |
+
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task=task)
|
39 |
+
|
40 |
+
text = pipe("audio_path.wav")["text"]
|
41 |
+
print(text)
|
42 |
+
```
|
43 |
|
44 |
## Evaluation Performance
|
45 |
Note: WER calculated with newmm tokenizer for Thai segmentation.
|