Den4ikAI commited on
Commit
d5c8fa2
·
verified ·
1 Parent(s): 38128ce

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -25
README.md CHANGED
@@ -29,7 +29,7 @@ language:
29
  - da
30
  - hu
31
  - ta
32
- - 'no'
33
  - th
34
  - ur
35
  - hr
@@ -110,65 +110,64 @@ pipeline_tag: automatic-speech-recognition
110
 
111
  # Den4ikAI/whisper-large-v2-no-digits-norm-punct
112
 
113
- Это специальная версия модели `openai/whisper-large-v2`, из словаря которой были удалены все токены, отвечающие за цифры, а также токены с мусорной пунктуацией.
114
 
115
- Основная цель этой модификации **заставить модель генерировать числа словами**, а не цифрами. Это крайне полезно для задач нормализации текста, например, при подготовке данных для систем синтеза речи (TTS), где требуется произносить числа полностью.
116
 
117
- ## Сравнение с оригинальной моделью
118
 
119
- Вот наглядный пример, демонстрирующий разницу в поведении моделей при распознавании одной и той же аудиозаписи с фразой "Билет стоил двадцать тысяч рублей".
120
 
121
- | Модель | Результат транскрипции |
122
- | ------------------------------------------- | ---------------------------------------------------------------------------------------------- |
123
- | `openai/whisper-large-v2` (Оригинал) | `<\|startoftranscript\|><\|ru\|><\|transcribe\|><\|notimestamps\|> Билет стоил **20000** рублей.<\|endoftext\|>` |
124
- | `Den4ikAI/whisper-large-v2-no-digits-norm-punct` (Эта модель) | `<\|startoftranscript\|><\|ru\|><\|transcribe\|><\|notimestamps\|> Билет стоил **двадцать тысяч** рублей.<\|endoftext\|>` |
125
 
126
- Как видно, эта модель корректно нормализовала число, в то время как оригинальная версия оставила его в виде цифр.
127
 
128
- ## Как использовать
129
 
130
- Вы можете использовать эту модель так же, как и любую другую модель Whisper в библиотеке `transformers`.
131
 
132
  ```python
133
  from transformers import WhisperProcessor, WhisperForConditionalGeneration
134
  import torchaudio
135
  import torch
136
 
137
- # Укажите устройство (GPU, если доступен)
138
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
139
 
140
-
141
  wav, sr = torchaudio.load("numbers5.mp3")
142
- # Преобразование в моно и ресемплинг до 16кГц
143
  if wav.shape[0] > 1:
144
  wav = torch.mean(wav, dim=0, keepdim=True)
145
  resampler = torchaudio.transforms.Resample(sr, 16000)
146
  wav = resampler(wav)
147
  audio_input = wav.squeeze(0)
148
 
149
- # Загрузка модели и процессора
150
  model_id = "Den4ikAI/whisper-large-v2-no-digits-norm-punct"
151
  processor = WhisperProcessor.from_pretrained(model_id)
152
  model = WhisperForConditionalGeneration.from_pretrained(model_id).to(device)
153
 
154
- # Обработка аудио и получение признаков
155
  input_features = processor(
156
- audio_input,
157
- sampling_rate=16000,
158
  return_tensors="pt"
159
  ).input_features.to(device)
160
 
161
- # Генерация токенов
162
- # Для русского языка указываем language="russian"
163
  predicted_ids = model.generate(input_features, language="russian", task="transcribe")
164
 
165
- # Декодирование в текст
166
  transcription = processor.batch_decode(
167
- predicted_ids,
168
- skip_special_tokens=False # Установите True, чтобы убрать <|...|> токены
169
  )
170
 
171
  print(transcription)
172
 
173
- # Пример вывода для аудио с числами:
174
  # ['<|startoftranscript|><|ru|><|transcribe|><|notimestamps|> Билет стоил двадцать тысяч рублей.<|endoftext|>']
 
29
  - da
30
  - hu
31
  - ta
32
+ - no
33
  - th
34
  - ur
35
  - hr
 
110
 
111
  # Den4ikAI/whisper-large-v2-no-digits-norm-punct
112
 
113
+ This is a special version of the `openai/whisper-large-v2` model whose vocabulary has had all tokens corresponding to digits removed, as well as tokens with extraneous punctuation.
114
 
115
+ The primary goal of this modification is to **force the model to generate numbers as words rather than digits**. This is extremely useful for text normalization tasks, for example when preparing data for text-to-speech (TTS) systems, where numbers need to be fully spelled out.
116
 
117
+ ## Comparison with the Original Model
118
 
119
+ Here’s a clear example demonstrating the difference in behavior between the models when transcribing the same audio clip containing the phrase “Билет стоил двадцать тысяч рублей” (“The ticket cost twenty thousand rubles”).
120
 
121
+ | Model | Transcription Output |
122
+ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
123
+ | `openai/whisper-large-v2` (Original) | `<\|startoftranscript\|><\|ru\|><\|transcribe\|><\|notimestamps\|> Билет стоил **20000** рублей.<\|endoftext\|>` |
124
+ | `Den4ikAI/whisper-large-v2-no-digits-norm-punct` (This model) | `<\|startoftranscript\|><\|ru\|><\|transcribe\|><\|notimestamps\|> Билет стоил **двадцать тысяч** рублей.<\|endoftext\|>` |
125
 
126
+ As you can see, this modified model correctly normalized the number into words, whereas the original version left it as digits.
127
 
128
+ ## How to Use
129
 
130
+ You can use this model just like any other Whisper model in the `transformers` library.
131
 
132
  ```python
133
  from transformers import WhisperProcessor, WhisperForConditionalGeneration
134
  import torchaudio
135
  import torch
136
 
137
+ # Specify the device (GPU if available)
138
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
139
 
140
+ # Load the audio file
141
  wav, sr = torchaudio.load("numbers5.mp3")
142
+ # Convert to mono and resample to 16 kHz
143
  if wav.shape[0] > 1:
144
  wav = torch.mean(wav, dim=0, keepdim=True)
145
  resampler = torchaudio.transforms.Resample(sr, 16000)
146
  wav = resampler(wav)
147
  audio_input = wav.squeeze(0)
148
 
149
+ # Load the processor and model
150
  model_id = "Den4ikAI/whisper-large-v2-no-digits-norm-punct"
151
  processor = WhisperProcessor.from_pretrained(model_id)
152
  model = WhisperForConditionalGeneration.from_pretrained(model_id).to(device)
153
 
154
+ # Prepare inputs and extract features
155
  input_features = processor(
156
+ audio_input,
157
+ sampling_rate=16000,
158
  return_tensors="pt"
159
  ).input_features.to(device)
160
 
161
+ # Generate token IDs (for Russian specify language="russian")
 
162
  predicted_ids = model.generate(input_features, language="russian", task="transcribe")
163
 
164
+ # Decode tokens back to text
165
  transcription = processor.batch_decode(
166
+ predicted_ids,
167
+ skip_special_tokens=False
168
  )
169
 
170
  print(transcription)
171
 
172
+ # Example output for an audio clip with numbers:
173
  # ['<|startoftranscript|><|ru|><|transcribe|><|notimestamps|> Билет стоил двадцать тысяч рублей.<|endoftext|>']