| 1 | /* manual_SpeechRecognizer.cpp |
| 2 | * |
| 3 | * Copyright (C) 2026 Anastasia Shchupak |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "ManPagesM.h"cxx . . $ `<file>/sys/ManPagesM.h`/ |
| 20 | |
| 21 | void manual_SpeechRecognizer_initcxx . . $ manual_SpeechRecognizer_init(e57bd08652fa63a5). (ManPagescxx . . $ ManPages# me); |
| 22 | void manual_SpeechRecognizer_initcxx . . $ manual_SpeechRecognizer_init(e57bd08652fa63a5). (ManPagescxx . . $ ManPages# me) { |
| 23 | |
| 24 | MAN_PAGES_BEGINcxx . . $ `sys/ManPagesM.h:27:9`! R"~~~( |
| 25 | ################################################################################ |
| 26 | "Speech recognition" |
| 27 | © Anastasia Shchupak 2026-06-01 |
| 28 | |
| 29 | There are two speech recognition tools available in Praat: automatic transcription (turning speech |
| 30 | into text) and automatic speaker diarization (finding out who speaks when). This tutorial |
| 31 | describes how you can use these tools in Praat. It assumes that you are familiar with the @Intro, |
| 32 | especially with @@Intro 7. Annotation@. |
| 33 | |
| 34 | Transcription is performed with @@whisper.cpp@ and it requires at least one external model |
| 35 | installed on your computer; diarization is performed with an adapted @@pyannote.audio@ |
| 36 | diarization pipeline and it works without any external models. Diarization can also be performed |
| 37 | together with transcription, so that transcribed text is divided between speakers. |
| 38 | |
| 39 | After you have read the chapters ##1. Automatic transcription# and ##2. Automatic speaker |
| 40 | diarization#, you might be interested in what can be done to improve the performance of these |
| 41 | tools in Praat; you can find this information in ##3. Performance#. |
| 42 | |
| 43 | 1. Automatic transcription |
| 44 | ========================== |
| 45 | Transcription in Praat turns speech in a @Sound object into written text. Usually you might want |
| 46 | this text to be placed into a @TextGrid, aligning it with the Sound (this is described in ##1.2. |
| 47 | Transcribing into a TextGrid#). But you can also obtain it as plain text (see ##1.3. Transcribing |
| 48 | into plain text#). Either way, you first need a Whisper model installed, and how to do that is |
| 49 | explained in ##1.1. Installing Whisper models#. |
| 50 | |
| 51 | 1.1. Installing Whisper models |
| 52 | ============================== |
| 53 | To transcribe, you need at least one Whisper model installed. In this case, installation |
| 54 | means downloading a model and placing it into a specific folder on your computer, where Praat |
| 55 | can later find it. In your Praat @@preferences folder@, create a folder called `models`, and |
| 56 | inside it another one called `whispercpp`. If you are on Windows, you will now have a folder called |
| 57 | something like `C:\Users\Your Name\Praat\models\whispercpp`. |
| 58 | |
| 59 | Models can be downloaded from `https://huggingface.co/ggerganov/whisper.cpp`. This |
| 60 | page contains Whisper models in ggml format (files with extension `.bin`), which is what |
| 61 | whisper.cpp uses. Note that the original Whisper models, by OpenAI, are distributed in PyTorch format |
| 62 | (files with extension `.pt`) and cannot be used in Praat directly: they first need to be |
| 63 | converted to ggml format. The files on the page above are results of such conversions. |
| 64 | |
| 65 | The list of available models is quite long, and you might wonder how to choose one. You will |
| 66 | probably want to experiment with different models to find a good balance between speed and |
| 67 | accuracy for your specific task, but below you can read a brief overview which can help you get |
| 68 | started. |
| 69 | |
| 70 | A model is English-only if its name contains `.en` (e.g. `ggml-small.en.bin`); all other models are |
| 71 | multilingual. Size-wise, the models range from `tiny` (about 75 MB) through `base`, `small` and |
| 72 | `medium` to `large` (about 2.9 GB). The large models have three different versions: `large-v1`, |
| 73 | `large-v2` and `large-v3`. The later versions are improvements over the earlier ones. Generally |
| 74 | speaking, larger models tend to be more accurate but use more disk space and memory, and take |
| 75 | longer to transcribe. So, `base` or `small` can be good starting points. |
| 76 | |
| 77 | Models whose names end in `-q5_0`, `-q5_1` or `-q8_0` are %quantized: their weights are stored with |
| 78 | fewer bits (5 or 8 instead of 16), so they take less disk space and memory, and run faster than the |
| 79 | normal (non-quantized) models with the corresponding names. There is also `large-v3-turbo`, |
| 80 | a reduced version of `large-v3` that has fewer decoder layers: it is about half the size and thus |
| 81 | faster than the original `large-v3`. These optimized model variants were created to offer better |
| 82 | speed at the cost of reduced accuracy. |
| 83 | |
| 84 | Once you have decided which model you want, download its `.bin` file and place it in your newly |
| 85 | created `whispercpp` folder. Any `.bin` file placed in this folder will be found by Praat. |
| 86 | In fact, if you want to experiment with different models, you can download |
| 87 | as many of them as you like; Praat will let you select one before you start transcription. |
| 88 | |
| 89 | 1.2. Transcribing into a TextGrid |
| 90 | ================================= |
| 91 | 1.2.1. How to start |
| 92 | =================== |
| 93 | You need a @Sound and a @TextGrid for this Sound (transcription modifies an existing TextGrid; |
| 94 | it does not create one). The TextGrid should have at least one interval tier: transcription is |
| 95 | run on one selected interval, so you need an interval tier to contain this interval. To |
| 96 | transcribe the whole Sound, you can use an interval tier without internal boundaries and thus |
| 97 | consisting of only one interval spanning the whole Sound (interval 1). |
| 98 | |
| 99 | There are two ways to start transcription into a TextGrid: |
| 100 | 1. from the @TextGridEditor, via the ##Transcribe interval# command in the #Interval menu; you can |
| 101 | get into the TextGridEditor by selecting the TextGrid and the Sound together in the @@Objects |
| 102 | window@ and choosing ##View & Edit# from the @@Dynamic menu@; |
| 103 | 2. from the Objects window itself, when you select the TextGrid and the Sound together and choose |
| 104 | @@TextGrid & Sound: Transcribe interval...@. |
| 105 | |
| 106 | These two ways achieve exactly the same result, and which one you use is a matter of preference. |
| 107 | They differ only in how you select the interval you want to transcribe (see ##1.2.4. Transcribe!#), |
| 108 | and whether the configured transcription settings are persistent across Praat sessions (see the |
| 109 | next two paragraphs). |
| 110 | |
| 111 | To perform transcription from the TextGridEditor, you first need to adjust the settings via |
| 112 | the separate command ##Transcription settings...# (in the #Interval menu). These settings are |
| 113 | preserved across transcription runs and across Praat sessions, so you can skip this step later |
| 114 | when you want to reuse the settings from the last time you transcribed. Note that the settings in |
| 115 | the ##Diarization...# block can also be configured via ##Diarization settings...# (also in the |
| 116 | #Interval menu), which is used by standalone diarization (see ##2. Automatic speaker diarization#). |
| 117 | This means that a change in diarization settings made in either place affects both |
| 118 | transcription-with-diarization and standalone diarization. |
| 119 | |
| 120 | If you are running transcription from the Objects window, all the transcription settings appear |
| 121 | in the ##Transcribe interval...# command window. In this window, settings are preserved across |
| 122 | transcription runs but not across Praat sessions. |
| 123 | |
| 124 | 1.2.2. How to configure settings |
| 125 | ================================ |
| 126 | There are three blocks of settings: ##Transcription...#, ##Non-speech detection...# and |
| 127 | ##Diarization...#. The last two configure optional steps in the transcription process; each |
| 128 | step can be switched on and off by the first setting in its block. |
| 129 | |
| 130 | The ##Transcription...# block has three settings: ##Whisper model#, #Language and ##Include words#. |
| 131 | |
| 132 | ##Whisper model# lists all the models you installed in ##1.1. Installing Whisper models#; now is |
| 133 | the time to choose the model that you want to use. If you find yourself at this step with an empty |
| 134 | model list, this means something went wrong at the installation step. You can go back to |
| 135 | ##1.1. Installing Whisper models# to check that the downloaded model(s) are placed in the proper |
| 136 | folder. After that, reopen ##Transcription settings...#; your installed model(s) will appear in |
| 137 | the list. |
| 138 | |
| 139 | #Language is the language you want to recognize; you can select it from the list of all |
| 140 | available languages or keep the default ##Autodetect language# (note that for an English-only model |
| 141 | you are not allowed to select a language other than #English or the default ##Autodetect |
| 142 | language#). |
| 143 | |
| 144 | The third transcription setting is ##Include words#. If this setting is on, an extra tier is |
| 145 | added to the TextGrid below the sentence tier, with one interval per word. If diarization is also |
| 146 | included (described below), each speaker gets their own word tier. Examples 2 and 4 below show the |
| 147 | resulting TextGrids when ##Include words# is on without and with diarization respectively. |
| 148 | |
| 149 | ##Non-speech detection...# is switched on and off by its first setting ##Detect non-speech#: when |
| 150 | it is on, the non-speech parts are first removed from the Sound, before it is passed to a Whisper |
| 151 | model. This both speeds up transcription and prevents the model from inventing text in the |
| 152 | non-speech parts. Another benefit of using non-speech detection is that it makes sentence and |
| 153 | word boundaries more precise; without it, the text might be stretched over the silent parts of |
| 154 | the Sound. See @@speech activity detection with Silero VAD@ for the description of the |
| 155 | settings influencing non-speech detection. |
| 156 | |
| 157 | ##Diarization...# is switched on and off by its first setting ##Include diarization#: when it is |
| 158 | on, diarization is also run on the Sound (independently of transcription). The results from both |
| 159 | transcription and diarization are then combined: transcribed text is divided between the detected |
| 160 | speakers. See @@speaker diarization with adapted pyannote.audio@ and ##2.2 How to configure |
| 161 | settings# for the description of the diarization settings. |
| 162 | |
| 163 | 1.2.3. Examples |
| 164 | =============== |
| 165 | The structure of the resulting TextGrid depends on the combination of ##Include words# and |
| 166 | ##Include diarization# settings. Four examples below show the different TextGrid outcomes for |
| 167 | different combinations of these two settings when the interval selected for transcription spans |
| 168 | the whole tier “Mary”. |
| 169 | |
| 170 | ##Example 1#: both ##Include words# and ##Include diarization# are off. The interval selected for |
| 171 | transcription is split into many intervals: one interval for each sentence containing the sentence |
| 172 | text, with empty intervals for non-speech parts. Sentence boundaries are defined by the punctuation |
| 173 | that whisper.cpp returns. No new tiers are inserted. |
| 174 | {- 6.0x3.0 |
| 175 | tierName$ = "Mary" |
| 176 | textgrid = Create TextGrid: 0, 11, tierName$, "" |
| 177 | Insert boundary: 1, 0.8 |
| 178 | Insert boundary: 1, 8.4 |
| 179 | Insert boundary: 1, 8.5 |
| 180 | Insert boundary: 1, 9.5 |
| 181 | Set interval text: 1, 2, "I start the sentence and I finish it." |
| 182 | Set interval text: 1, 4, "Right." |
| 183 | Draw: 0.0, 0.0, 1, 1, 1 |
| 184 | Axes: 0, 100, 0, 7 |
| 185 | One mark right: 0.7, 0, 0, 0, tierName$ |
| 186 | selectObject: textgrid |
| 187 | Remove |
| 188 | } |
| 189 | |
| 190 | ##Example 2#: ##Include words# is on and ##Include diarization# is off. The original interval |
| 191 | is split into sentences as in ##Example 1#, plus a tier called “Mary/word” is added just below |
| 192 | “Mary”, with one interval per word. |
| 193 | {- 6.0x3.0 |
| 194 | tier1Name$ = "Mary" |
| 195 | tier2Name$ = "Mary/word" |
| 196 | textgrid = Create TextGrid: 0, 11, tier1Name$ + " " + tier2Name$, "" |
| 197 | Insert boundary: 1, 0.8 |
| 198 | Insert boundary: 1, 8.4 |
| 199 | Insert boundary: 1, 8.5 |
| 200 | Insert boundary: 1, 9.5 |
| 201 | Insert boundary: 2, 0.8 |
| 202 | Insert boundary: 2, 1.6 |
| 203 | Insert boundary: 2, 2.3 |
| 204 | Insert boundary: 2, 2.7 |
| 205 | Insert boundary: 2, 3.2 |
| 206 | Insert boundary: 2, 4.8 |
| 207 | Insert boundary: 2, 5.1 |
| 208 | Insert boundary: 2, 5.7 |
| 209 | Insert boundary: 2, 6.5 |
| 210 | Insert boundary: 2, 6.7 |
| 211 | Insert boundary: 2, 7.8 |
| 212 | Insert boundary: 2, 8.1 |
| 213 | Insert boundary: 2, 8.4 |
| 214 | Insert boundary: 2, 8.5 |
| 215 | Insert boundary: 2, 9.5 |
| 216 | Set interval text: 1, 2, "I start the sentence and I finish it." |
| 217 | Set interval text: 1, 4, "Right." |
| 218 | Set interval text: 2, 2, "I" |
| 219 | Set interval text: 2, 3, "start" |
| 220 | Set interval text: 2, 5, "the" |
| 221 | Set interval text: 2, 6, "sentence" |
| 222 | Set interval text: 2, 8, "and" |
| 223 | Set interval text: 2, 10, "I" |
| 224 | Set interval text: 2, 11, "finish" |
| 225 | Set interval text: 2, 13, "it" |
| 226 | Set interval text: 2, 15, "Right" |
| 227 | Draw: 0.0, 0.0, 1, 1, 1 |
| 228 | Axes: 0, 100, 0, 7 |
| 229 | One mark right: 0.6, 0, 0, 0, tier2Name$ |
| 230 | One mark right: 1.7, 0, 0, 0, tier1Name$ |
| 231 | selectObject: textgrid |
| 232 | Remove |
| 233 | } |
| 234 | |
| 235 | ##Example 3#: ##Include words# is off and ##Include diarization# is on (and diarization detects |
| 236 | at least two speakers). Tier “Mary” is renamed to “Mary/sp1” and additional tiers “Mary/sp2”, |
| 237 | “Mary/sp3”, ... are added, one tier per detected speaker. Each speaker’s tier contains the |
| 238 | intervals with the sentences spoken by that speaker. It is possible that a sentence is started by |
| 239 | one speaker and finished by another one. In this case the sentence is split between these |
| 240 | speakers’ tiers. |
| 241 | {- 6.0x3.0 |
| 242 | tier1Name$ = "Mary/sp1" |
| 243 | tier2Name$ = "Mary/sp2" |
| 244 | textgrid = Create TextGrid: 0, 11, tier1Name$ + " " + tier2Name$, "" |
| 245 | Insert boundary: 1, 0.8 |
| 246 | Insert boundary: 1, 4.8 |
| 247 | Insert boundary: 2, 5.1 |
| 248 | Insert boundary: 2, 8.4 |
| 249 | Insert boundary: 1, 8.5 |
| 250 | Insert boundary: 1, 9.5 |
| 251 | Set interval text: 1, 2, "I start the sentence..." |
| 252 | Set interval text: 2, 2, "... and I finish it." |
| 253 | Set interval text: 1, 4, "Right." |
| 254 | Draw: 0.0, 0.0, 1, 1, 1 |
| 255 | Axes: 0, 100, 0, 7 |
| 256 | One mark right: 0.6, 0, 0, 0, tier2Name$ |
| 257 | One mark right: 1.7, 0, 0, 0, tier1Name$ |
| 258 | selectObject: textgrid |
| 259 | Remove |
| 260 | } |
| 261 | |
| 262 | ##Example 4#: both ##Include words# and ##Include diarization# are on. In addition to a |
| 263 | sentence tier, each speaker also gets a word tier (“Mary/sp1/w” for speaker 1, “Mary/sp2/w” for |
| 264 | speaker 2, ...), which is inserted directly after their sentence tier. |
| 265 | {- 6.0x3.0 |
| 266 | tier1Name$ = "Mary/sp1" |
| 267 | tier2Name$ = "Mary/sp1/w" |
| 268 | tier3Name$ = "Mary/sp2" |
| 269 | tier4Name$ = "Mary/sp2/w" |
| 270 | textgrid = Create TextGrid: 0, 11, tier1Name$ + " " + tier2Name$ + " " + tier3Name$ + " " + tier4Name$, "" |
| 271 | Insert boundary: 1, 0.8 |
| 272 | Insert boundary: 1, 4.8 |
| 273 | Insert boundary: 3, 5.1 |
| 274 | Insert boundary: 3, 8.4 |
| 275 | Insert boundary: 1, 8.5 |
| 276 | Insert boundary: 1, 9.5 |
| 277 | Set interval text: 1, 2, "I start the sentence..." |
| 278 | Set interval text: 3, 2, "... and I finish it." |
| 279 | Set interval text: 1, 4, "Right." |
| 280 | Insert boundary: 2, 0.8 |
| 281 | Insert boundary: 2, 1.6 |
| 282 | Insert boundary: 2, 2.3 |
| 283 | Insert boundary: 2, 2.7 |
| 284 | Insert boundary: 2, 3.2 |
| 285 | Insert boundary: 2, 4.8 |
| 286 | Insert boundary: 2, 8.5 |
| 287 | Insert boundary: 2, 9.5 |
| 288 | Insert boundary: 4, 5.1 |
| 289 | Insert boundary: 4, 5.7 |
| 290 | Insert boundary: 4, 6.5 |
| 291 | Insert boundary: 4, 6.7 |
| 292 | Insert boundary: 4, 7.8 |
| 293 | Insert boundary: 4, 8.1 |
| 294 | Insert boundary: 4, 8.4 |
| 295 | Set interval text: 2, 2, "I" |
| 296 | Set interval text: 2, 3, "start" |
| 297 | Set interval text: 2, 5, "the" |
| 298 | Set interval text: 2, 6, "sentence" |
| 299 | Set interval text: 4, 2, "and" |
| 300 | Set interval text: 4, 4, "I" |
| 301 | Set interval text: 4, 5, "finish" |
| 302 | Set interval text: 4, 7, "it" |
| 303 | Set interval text: 2, 8, "Right" |
| 304 | Draw: 0.0, 0.0, 1, 1, 1 |
| 305 | Axes: 0, 100, 0, 7 |
| 306 | One mark right: 0.45, 0, 0, 0, tier4Name$ |
| 307 | One mark right: 1.3, 0, 0, 0, tier3Name$ |
| 308 | One mark right: 2.15, 0, 0, 0, tier2Name$ |
| 309 | One mark right: 3, 0, 0, 0, tier1Name$ |
| 310 | selectObject: textgrid |
| 311 | Remove |
| 312 | } |
| 313 | |
| 314 | 1.2.4. Transcribe! |
| 315 | ================== |
| 316 | With the transcription settings configured, you are now ready to start the transcription. |
| 317 | |
| 318 | If you are transcribing from the TextGridEditor, select the interval you want to transcribe by |
| 319 | clicking on it and choose ##Transcribe interval# from the #Interval menu. |
| 320 | |
| 321 | If you are transcribing from the Objects window, use the settings ##Tier number# and ##Interval |
| 322 | number# at the top of the ##Transcribe interval...# command window to specify the interval you |
| 323 | want to transcribe. |
| 324 | |
| 325 | In either case, note that you cannot transcribe an interval belonging to a tier whose name already |
| 326 | contains a slash. This is to prevent endlessly growing names of the derived tiers. |
| 327 | |
| 328 | Running transcription takes some time; how long it takes depends on the length of the selected |
| 329 | interval, the Whisper model, and whether diarization is included. Please read ##3. Performance# |
| 330 | if you would like to make transcription run faster. |
| 331 | |
| 332 | 1.3. Transcribing into plain text |
| 333 | ================================= |
| 334 | You can also transcribe a whole @Sound into plain text. For this you need a @SpeechRecognizer |
| 335 | object. You can create one by choosing @@Create SpeechRecognizer...@ from the @@New menu@ |
| 336 | in the @@Objects window@. A command window will appear containing two settings: ##Whisper model# |
| 337 | and #Language, both of which are described in ##1.2.2. How to configure settings#. After you |
| 338 | click #OK, you will find a new #SpeechRecognizer object in the object list. |
| 339 | |
| 340 | To transcribe, select the SpeechRecognizer object and the Sound object together and choose |
| 341 | ##SpeechRecognizer & Sound: Transcribe# from the @@Dynamic menu@. The result of transcription will |
| 342 | be written to the @@Info window@. Note that the ##Detect non-speech# setting is not available here: |
| 343 | @@speech activity detection with Silero VAD|Silero VAD@ is always on, with default settings. |
| 344 | |
| 345 | 2. Automatic speaker diarization |
| 346 | ================================ |
| 347 | Diarization in Praat detects different speakers in a @Sound. For each detected speaker, it |
| 348 | identifies %%speech segments%, which are time intervals during which this speaker is active. |
| 349 | Diarization can be done as part of transcription or standalone. In either case, it modifies an |
| 350 | existing @TextGrid, producing one interval tier for each detected speaker. |
| 351 | |
| 352 | Diarization settings (see ##2.2. How to configure settings#) are shared between standalone |
| 353 | diarization and diarization as part of transcription. Everything else in this chapter is specific |
| 354 | to standalone diarization; the transcription-with-diarization case is described in ##1.2. |
| 355 | Transcribing into a TextGrid#. |
| 356 | |
| 357 | 2.1. How to start |
| 358 | ================= |
| 359 | To perform diarization, you need a @Sound and a @TextGrid for this Sound (diarization modifies an |
| 360 | existing TextGrid; it does not create one). The TextGrid should have at least one interval tier: |
| 361 | diarization is run on one selected interval, so you need an interval tier to contain this |
| 362 | interval. To diarize the whole Sound, you can use an interval tier without internal boundaries |
| 363 | and thus consisting of only one interval spanning the whole Sound (interval 1). |
| 364 | |
| 365 | There are two ways to start diarization: |
| 366 | 1. from the @TextGridEditor, via the ##Diarize interval# command in the #Interval menu; you can |
| 367 | get into the TextGridEditor by selecting the TextGrid and the Sound together in the @@Objects |
| 368 | window@ and choosing ##View & Edit# from the @@Dynamic menu@; |
| 369 | 2. from the Objects window itself, when you select the TextGrid and the Sound together and choose |
| 370 | @@TextGrid & Sound: Diarize interval...@. |
| 371 | |
| 372 | These two ways achieve exactly the same result, and which one you use is a matter of preference. |
| 373 | They differ only in how you select the interval you want to diarize (see ##2.4. Diarize!#), |
| 374 | and whether the configured diarization settings are persistent across Praat sessions (see the |
| 375 | next two paragraphs). |
| 376 | |
| 377 | To perform diarization from the TextGridEditor, you first need to adjust the settings via |
| 378 | the separate command ##Diarization settings...# (in the #Interval menu). These settings are |
| 379 | preserved across diarization runs and across Praat sessions, so you can skip this step later |
| 380 | when you want to reuse the settings from your last diarization run. Note that the diarization |
| 381 | settings are shared between standalone diarization and transcription-with-diarization. So if you |
| 382 | last changed them via ##Transcription settings...#, it is worth checking them before you run |
| 383 | diarization. |
| 384 | |
| 385 | If you are running diarization from the Objects window, all the diarization settings appear |
| 386 | in the ##Diarize interval...# command window. In this window, settings are preserved across |
| 387 | diarization runs but not across Praat sessions. |
| 388 | |
| 389 | 2.2. How to configure settings |
| 390 | ============================== |
| 391 | ##Non-speech interval label# and ##Speech interval label# are the labels in the resulting TextGrid |
| 392 | assigned to intervals classified as non-speech and speech respectively. These two settings only |
| 393 | influence the visual appearance of the result of diarization but not the result itself. |
| 394 | |
| 395 | ##Max. number of speakers (≥ 2)# and ##Clustering threshold (0-2)# both influence how many |
| 396 | speakers diarization detects. ##Max. number of speakers (≥ 2)# defines an upper limit on the number |
| 397 | of detected speakers, and while there is no equivalent setting for the lower limit, ##Clustering |
| 398 | threshold (0-2)# can be used to push this number up. These two settings can be used to improve the |
| 399 | quality of diarization if you know exactly how many speakers are in your Sound. If this is |
| 400 | the case, you might find the following recipe useful: |
| 401 | 1. set the ##Max. number of speakers (≥ 2)# to the number of active speakers; |
| 402 | 2. do a test diarization run on (a part of) your Sound; |
| 403 | 3. if fewer speakers were detected than are active in the Sound, then try lowering the |
| 404 | ##Clustering threshold (0-2)#, perhaps making it 0.1 lower than it is now. |
| 405 | |
| 406 | Repeat steps 2 and 3 until diarization detects the correct number of speakers. |
| 407 | |
| 408 | Tweaking the ##Clustering threshold (0-2)# might especially help when the voices of the speakers |
| 409 | are similar, or when recording is done in a noisy environment. If you would like to know the |
| 410 | details of what clustering threshold is and why it works this way, please read the #Algorithm |
| 411 | section of @@speaker diarization with adapted pyannote.audio@, specifically the part about |
| 412 | #Clustering. |
| 413 | |
| 414 | The ##Allow speakers to overlap# setting does what its name suggests: if it is on, diarization |
| 415 | can detect when two speakers are speaking at the same time. Note that diarization does not detect |
| 416 | overlap of three or more speakers. |
| 417 | |
| 418 | The last setting, ##Segmentation step (0-1)#, can be used to find a balance between speed and |
| 419 | accuracy. You can read more about it in ##3. Performance#. To start with, you can keep its |
| 420 | standard value of 0.1. |
| 421 | |
| 422 | 2.3. Example |
| 423 | ============ |
| 424 | This example shows the result of a standalone diarization run on the same Sound as in ##1.2.3. |
| 425 | Examples#; the interval selected for diarization spans the whole tier “Mary”. Diarization detects |
| 426 | two speakers, so tier “Mary” is renamed to “Mary/sp1”, and the second tier “Mary/sp2” is added. |
| 427 | Each speaker’s tier contains alternating intervals: non-speech and speech intervals labelled with |
| 428 | the configured ##Non-speech interval label# (blank in this case) and ##Speech interval label# |
| 429 | (“speech” in this case), respectively. |
| 430 | {- 6.0x3.0 |
| 431 | tier1Name$ = "Mary/sp1" |
| 432 | tier2Name$ = "Mary/sp2" |
| 433 | textgrid = Create TextGrid: 0, 11, tier1Name$ + " " + tier2Name$, "" |
| 434 | Insert boundary: 1, 0.8 |
| 435 | Insert boundary: 1, 4.8 |
| 436 | Insert boundary: 2, 5.1 |
| 437 | Insert boundary: 2, 8.4 |
| 438 | Insert boundary: 1, 8.5 |
| 439 | Insert boundary: 1, 9.5 |
| 440 | Set interval text: 1, 2, "speech" |
| 441 | Set interval text: 2, 2, "speech" |
| 442 | Set interval text: 1, 4, "speech" |
| 443 | Draw: 0.0, 0.0, 1, 1, 1 |
| 444 | Axes: 0, 100, 0, 7 |
| 445 | One mark right: 0.6, 0, 0, 0, tier2Name$ |
| 446 | One mark right: 1.7, 0, 0, 0, tier1Name$ |
| 447 | selectObject: textgrid |
| 448 | Remove |
| 449 | } |
| 450 | |
| 451 | 2.4. Diarize! |
| 452 | ============= |
| 453 | With the diarization settings configured, you are now ready to start the diarization. |
| 454 | |
| 455 | If you are diarizing from the TextGridEditor, select the interval you want to diarize by |
| 456 | clicking on it and choose ##Diarize interval# from the #Interval menu. |
| 457 | |
| 458 | If you are diarizing from the Objects window, use the settings ##Tier number# and ##Interval |
| 459 | number# at the top of the ##Diarize interval...# command window to specify the interval you |
| 460 | want to diarize. |
| 461 | |
| 462 | In either case, note that you cannot diarize an interval belonging to a tier whose name already |
| 463 | contains a slash. This is to prevent endlessly growing names of the derived tiers. |
| 464 | |
| 465 | Running diarization takes some time; how long it takes depends on the length of the selected |
| 466 | interval and on the diarization settings. Please read ##3. Performance# if you would like to make |
| 467 | diarization run faster. |
| 468 | |
| 469 | 3. Performance |
| 470 | ============== |
| 471 | Speech recognition tools in Praat rely on neural models, which consume a lot of computational |
| 472 | resources. So the time spent on transcription and diarization might become an obstacle to using |
| 473 | them, especially if you need to analyse a corpus or a large set of recordings. This chapter offers |
| 474 | some advice on how you can try to make speech recognition tools run faster. |
| 475 | |
| 476 | 3.1. AI settings |
| 477 | ================ |
| 478 | Most modern computers have several %%physical processors%. Each physical processor can process one |
| 479 | or two threads that run computations in parallel. The number of threads that a computer can run |
| 480 | in parallel is the number of its %%logical processors%. |
| 481 | |
| 482 | A reasonable assumption would be that transcription and diarization run fastest when Praat uses as |
| 483 | many threads as the computer has logical processors. However, in practice, using that many threads |
| 484 | can cause a dramatic slowdown on some computers. The question is then: exactly how many threads |
| 485 | is best to use? Unfortunately, the answer depends on the computer’s hardware architecture in ways |
| 486 | that are difficult to predict in advance. But it appears from our tests that half of the |
| 487 | available logical processors is a safe starting point that avoids the worst slowdowns, so this is |
| 488 | the default Praat uses for both transcription and diarization. If you suspect that this default |
| 489 | is not optimal for your computer, or if you would like to experiment, you can change it in ##AI |
| 490 | settings...#, which you can find in the #Settings submenu of the @@Praat menu@. But keep in mind |
| 491 | that it is probably better not to use more threads than the number of logical processors your |
| 492 | computer has. |
| 493 | |
| 494 | The optimal number of threads can differ between transcription and diarization, because they use |
| 495 | different models and parallelize their work in different ways. So it is better to tune them |
| 496 | separately: |
| 497 | - to tune transcription, change its ##Max. number of threads# and measure the time spent on |
| 498 | transcription %without diarization; |
| 499 | - to tune diarization, change its ##Max. number of threads# and measure the time spent on |
| 500 | standalone diarization. |
| 501 | |
| 502 | 3.2. Other ways to make transcription faster |
| 503 | ============================================ |
| 504 | The choice of Whisper model has a strong influence on how long transcription takes. If your |
| 505 | transcription is too slow, you can try to switch to a smaller or a quantized model. You can read |
| 506 | more about available models in ##1.1. Installing Whisper models#. |
| 507 | |
| 508 | Switching on ##Detect non-speech# (see ##1.2.2. How to configure settings#) also speeds up |
| 509 | transcription, especially on a Sound that contains a lot of parts without speech. This is because |
| 510 | non-speech parts are removed before the Sound is passed to a Whisper model, making the sound that |
| 511 | is actually analysed shorter. This is the setting which you may want to have always on, because |
| 512 | it also improves accuracy of the detected word and sentence boundaries. |
| 513 | |
| 514 | If you use transcription with diarization (##Include diarization# setting is on), then the |
| 515 | overall time also depends on how fast diarization is. |
| 516 | |
| 517 | 3.3. Other ways to make diarization faster |
| 518 | ========================================== |
| 519 | The ##Segmentation step (0-1)# setting (described in detail in @@speaker diarization with adapted |
| 520 | pyannote.audio@) controls the overlap between successive 10-second analysis windows and therefore |
| 521 | the overall number of analysis windows that the segmentation model processes. The segmentation |
| 522 | step itself is a distance between the starts of two consecutive windows as a fraction of the |
| 523 | window length, but the smaller this distance, the bigger the overlap. |
| 524 | |
| 525 | For example, a segmentation step of 0.1 makes this distance 1 second, so that two consecutive |
| 526 | windows have a 90\% overlap. Doubling the step value to 0.2 reduces the overlap to 80\% and |
| 527 | halves the overall number of analysis windows the model has to process; as a result |
| 528 | diarization runs roughly twice as fast. Increasing the step value to 0.5 further reduces |
| 529 | the analysis window overlap, making diarization run approximately five times faster. |
| 530 | |
| 531 | But the price for this speedup is reduced accuracy. After processing all analysis windows, the |
| 532 | diarization algorithm reconstructs the result for the whole Sound by averaging the model’s |
| 533 | predictions across the all the analysis windows. Less window overlap |
| 534 | means averaging across fewer windows, which produces less accurate results. |
| 535 | |
| 536 | If you want to speed up your diarization, you may experiment with increasing this value. But |
| 537 | perhaps it’s best to keep it below 0.5 so that every moment in the sound is analysed at least in |
| 538 | two analysis windows. |
| 539 | |
| 540 | ################################################################################ |
| 541 | "speech activity detection with Silero VAD" |
| 542 | © Anastasia Shchupak 2026-06-01 |
| 543 | |
| 544 | Praat uses the @@whisper.cpp@ implementation of the @@Silero VAD@ speech activity detector. |
| 545 | The pre-trained Silero VAD model weights have been converted to ggml format and compiled into Praat, |
| 546 | so no external model files are required. The sound is automatically resampled to 16 kHz |
| 547 | (the sampling frequency expected by the Silero VAD model) before being processed by the model. |
| 548 | |
| 549 | Purpose |
| 550 | ======= |
| 551 | to detect which parts of a sound contain speech. The output is a list of speech segments, |
| 552 | each defined by a start and an end time. |
| 553 | |
| 554 | Algorithm |
| 555 | ========= |
| 556 | The Silero VAD model processes the sound in fixed frames of 512 samples (32 ms, since the sound |
| 557 | is resampled to 16 kHz). For each frame, it outputs a probability that the frame contains speech. |
| 558 | Based on this output, the list of speech segments is constructed as described below. This |
| 559 | description reflects the whisper.cpp implementation, which differs slightly from Silero’s |
| 560 | original implementation. |
| 561 | |
| 562 | A speech segment begins at the first frame whose speech probability exceeds the ##Speech probability |
| 563 | threshold#. The segment continues as long as the speech probability stays above a lower threshold |
| 564 | (called the “negative threshold” in the Silero source code, equal to the speech probability |
| 565 | threshold minus 0.15). The segment ends only when the probability stays below the negative |
| 566 | threshold for at least ##Min. gap between speech segments#. When a segment ends, it is kept only |
| 567 | if it is longer than ##Min. speech segment#. |
| 568 | |
| 569 | After all segments have been formed, segments separated by a gap shorter than 0.2 s are merged |
| 570 | (this is hardcoded in whisper.cpp and not configurable). After that, padding is applied: each |
| 571 | segment is extended on both sides by ##Padding around speech segments#. If padding would cause |
| 572 | two segments to overlap, they instead meet at the midpoint of the gap between them. |
| 573 | |
| 574 | The result is a list of speech segments. |
| 575 | |
| 576 | Settings |
| 577 | ======== |
| 578 | ##Speech probability threshold (0-1)# (standard value: 0.5) |
| 579 | : determines the sensitivity of the speech detector. Higher values make the detector less |
| 580 | sensitive, meaning that a frame requires a higher speech probability to be considered part of |
| 581 | a speech segment. This reduces false positives (non-speech incorrectly classified as speech), |
| 582 | but may cause some speech to be missed. Lower values make the detector more sensitive. The |
| 583 | default of 0.5 works well for most use cases. |
| 584 | |
| 585 | ##Min. gap between speech segments (s)# (standard value: 0.1) |
| 586 | : the minimum duration of a gap between two speech segments. You might want to increase this value |
| 587 | if short silences within speech (e.g. plosive closures) are splitting speech into multiple |
| 588 | segments. Note that gaps shorter than 0.2 s are removed from the output (with their adjacent |
| 589 | speech segments merged), regardless of this setting. |
| 590 | |
| 591 | ##Min. speech segment (s)# (standard value: 0.25) |
| 592 | : the minimum duration of a speech segment. Shorter segments are discarded. |
| 593 | |
| 594 | ##Padding around speech segments (s)# (standard value: 0.0) |
| 595 | : extends each detected speech segment by this amount on both sides. You might want to increase |
| 596 | this value if speech onsets and offsets are being clipped. |
| 597 | |
| 598 | Availability in Praat |
| 599 | ===================== |
| 600 | Silero VAD speech activity detection is available in Praat: |
| 601 | - as part of transcription, running just before it to remove non-speech regions from the |
| 602 | analysed sound (see @@transcription with whisper.cpp@); |
| 603 | - standalone, producing a new @TextGrid with non-speech and speech intervals (see @@Sound: To |
| 604 | TextGrid (speech activity, Silero)...@). |
| 605 | |
| 606 | ################################################################################ |
| 607 | "Sound: To TextGrid (speech activity, Silero)..." |
| 608 | © Anastasia Shchupak 2026-06-01 |
| 609 | |
| 610 | A command that creates a @TextGrid with one interval tier from every selected @Sound object. |
| 611 | The interval tier contains non-speech and speech intervals with boundaries determined by the |
| 612 | Silero VAD model (for the algorithm and settings, see @@speech activity detection with Silero VAD@). |
| 613 | The labels of the intervals are specified by the settings ##Non-speech interval label# and ##Speech |
| 614 | interval label#. |
| 615 | |
| 616 | Settings |
| 617 | ======== |
| 618 | ##Speech probability threshold (0-1)# (standard value: 0.5) |
| 619 | : see @@speech activity detection with Silero VAD@. |
| 620 | |
| 621 | ##Min. gap between speech segments (s)# (standard value: 0.1) |
| 622 | : see @@speech activity detection with Silero VAD@. |
| 623 | |
| 624 | ##Min. speech segment (s)# (standard value: 0.25) |
| 625 | : see @@speech activity detection with Silero VAD@. |
| 626 | |
| 627 | ##Padding around speech segments (s)# (standard value: 0.0) |
| 628 | : see @@speech activity detection with Silero VAD@. |
| 629 | |
| 630 | ##Non-speech interval label# (standard value: “”) |
| 631 | : the label assigned to intervals classified as non-speech in the resulting TextGrid. |
| 632 | |
| 633 | ##Speech interval label# (standard value: “speech”) |
| 634 | : the label assigned to intervals classified as speech in the resulting TextGrid. |
| 635 | |
| 636 | ################################################################################ |
| 637 | "transcription with whisper.cpp" |
| 638 | © Anastasia Shchupak 2026-06-01 |
| 639 | |
| 640 | Praat can perform automatic transcription of a sound using @@whisper.cpp@. To do this, at least |
| 641 | one Whisper model must be installed on your computer. You can find the details about how to |
| 642 | install models and how to use transcription in the @@Speech recognition@ tutorial. The sound is |
| 643 | automatically resampled to 16 kHz (the sampling frequency expected by whisper.cpp) before being |
| 644 | transcribed. This page documents the transcription settings. |
| 645 | |
| 646 | Behaviour |
| 647 | ========= |
| 648 | When transcription is run on a @TextGrid interval, it modifies the TextGrid: intervals are split, |
| 649 | tiers may be added or renamed. The exact resulting TextGrid structure depends on the combination |
| 650 | of the ##Include words# and ##Include diarization# settings. See the @@Speech recognition@ tutorial |
| 651 | for the details of the transcription output under different combinations of these settings. |
| 652 | |
| 653 | Settings |
| 654 | ======== |
| 655 | ##Whisper model# |
| 656 | : determines which Whisper model is used. |
| 657 | The list is populated with the `.bin` files found in the `whispercpp` subfolder of the |
| 658 | `models` folder in the Praat preferences folder. See the @@Speech recognition@ tutorial for |
| 659 | details on how to install models. |
| 660 | |
| 661 | ##Language# (standard value: ##Autodetect language#) |
| 662 | : determines the language to be used for transcription. |
| 663 | Choose ##Autodetect language# to let the model detect the language automatically. If you know |
| 664 | the language you want to use for transcription, selecting it explicitly may improve |
| 665 | transcription accuracy. Note that English-only models (those with ##.en# in the name) can only |
| 666 | be used with ##Autodetect language# or ##English#. |
| 667 | |
| 668 | ##Include words# (standard: on) |
| 669 | : if on, each transcribed word is given a start and an end time, computed using whisper.cpp’s |
| 670 | internal dynamic time warping (DTW) algorithm. |
| 671 | |
| 672 | ##Detect non-speech# (standard: on) |
| 673 | : if on, @@speech activity detection with Silero VAD@ runs before transcription to identify |
| 674 | speech regions. Only those regions are then passed to the Whisper model. This generally |
| 675 | improves both speed and accuracy of transcription. Speed is improved by reducing the length of |
| 676 | the sound sent to the model, and accuracy by preventing the model from hallucinating text for |
| 677 | silent regions. |
| 678 | |
| 679 | ##Speech probability threshold (0-1)# (standard value: 0.5) |
| 680 | : see @@speech activity detection with Silero VAD@. |
| 681 | |
| 682 | ##Min. gap between speech segments (s)# (standard value: 0.1) |
| 683 | : see @@speech activity detection with Silero VAD@. |
| 684 | |
| 685 | ##Min. speech segment (s)# (standard value: 0.25) |
| 686 | : see @@speech activity detection with Silero VAD@. |
| 687 | |
| 688 | ##Padding around speech segments (s)# (standard value: 0.0) |
| 689 | : see @@speech activity detection with Silero VAD@. |
| 690 | |
| 691 | ##Include diarization# (standard: off) |
| 692 | : if on, speaker diarization is run alongside transcription (see @@speaker diarization with |
| 693 | adapted pyannote.audio@). The results of both are later combined to attribute portions of |
| 694 | transcribed speech to different speakers. |
| 695 | |
| 696 | ##Max. number of speakers (≥ 2)# (standard value: 2) |
| 697 | : see @@speaker diarization with adapted pyannote.audio@. |
| 698 | |
| 699 | ##Allow speakers to overlap# (standard: on) |
| 700 | : see @@speaker diarization with adapted pyannote.audio@. |
| 701 | |
| 702 | ##Clustering threshold (0-2)# (standard value: 0.7) |
| 703 | : see @@speaker diarization with adapted pyannote.audio@. |
| 704 | |
| 705 | ##Segmentation step (0-1)# (standard value: 0.1) |
| 706 | : see @@speaker diarization with adapted pyannote.audio@. |
| 707 | |
| 708 | Availability in Praat |
| 709 | ===================== |
| 710 | Transcription with whisper.cpp is available in two ways in Praat: |
| 711 | - if you select a @Sound together with its @TextGrid and choose |
| 712 | @@TextGrid & Sound: Transcribe interval...|Transcribe interval...@; |
| 713 | - via ##Transcribe interval# from the #Interval menu in the @TextGridEditor. |
| 714 | The settings for this command are set via ##Transcription settings...# in the same menu |
| 715 | and are remembered across Praat sessions. |
| 716 | |
| 717 | ################################################################################ |
| 718 | "TextGrid & Sound: Transcribe interval..." |
| 719 | © Anastasia Shchupak 2026-06-01 |
| 720 | |
| 721 | This command takes a specified interval of the @TextGrid, transcribes the corresponding part |
| 722 | of the @Sound, and writes the result back into the TextGrid. |
| 723 | |
| 724 | Settings |
| 725 | ======== |
| 726 | ##Tier number |
| 727 | : the number of the tier containing the interval to be transcribed. |
| 728 | |
| 729 | ##Interval number |
| 730 | : the number of the interval to be transcribed. |
| 731 | |
| 732 | The remaining settings in this dialog control the transcription itself; see @@transcription with |
| 733 | whisper.cpp@ for their meaning. |
| 734 | |
| 735 | ################################################################################ |
| 736 | "speaker diarization with adapted pyannote.audio" |
| 737 | © Anastasia Shchupak 2026-06-01 |
| 738 | |
| 739 | Speaker diarization detects which parts of a sound contain speech, and attributes each |
| 740 | part to one or more speakers. The output is a list of segments, each segment defined by a start |
| 741 | time, an end time and a speaker identifier. Speaker identifiers are natural numbers (1, 2, 3, ...); |
| 742 | they are arbitrary labels that roughly follow the order in which the speakers first appear in the |
| 743 | sound. |
| 744 | |
| 745 | Diarization in Praat always modifies an existing TextGrid by producing one tier per detected |
| 746 | speaker. It can be done as part of transcription (so that the transcribed text is split between |
| 747 | speaker tiers) or standalone (so that each speaker tier contains the intervals labelled as |
| 748 | non-speech or speech). See @@Speech recognition@ tutorial for details on how to use it. |
| 749 | |
| 750 | Praat performs speaker diarization using a C++/ggml adaptation of @@pyannote.audio@’s |
| 751 | `pyannote/speaker-diarization-3.1` pipeline. The two neural models used by the pipeline, |
| 752 | `pyannote/segmentation-3.0` (for segmentation) and `wespeaker-voxceleb-resnet34-LM` (for |
| 753 | speaker embedding, see @@WeSpeaker@), have been converted to ggml format and compiled into Praat, |
| 754 | so no external model files are required. The sound is automatically resampled to 16 kHz |
| 755 | (the sampling frequency expected by both models) before being processed. |
| 756 | |
| 757 | Settings |
| 758 | ======== |
| 759 | ##Max. number of speakers (≥ 2)# (standard value: 2) |
| 760 | : an upper bound on the number of speakers the algorithm may produce. Must be at least 2. There |
| 761 | is no matching “minimum number of speakers” setting; if you want to push the algorithm towards |
| 762 | distinguishing more speakers, you might try lowering the ##Clustering threshold#. |
| 763 | |
| 764 | ##Allow speakers to overlap# (standard: on) |
| 765 | : if on, at most two speakers may be active at the same moment. If off, every moment is |
| 766 | attributed to a single speaker, the one most active at that moment. |
| 767 | |
| 768 | ##Clustering threshold (0-2)# (standard value: 0.7) |
| 769 | : controls the number of detected speakers. Lower thresholds produce more speakers (but anyway |
| 770 | up to ##Max. number of speakers (≥ 2)#); higher thresholds produce fewer speakers. This is |
| 771 | the setting that can push the number of detected speakers up, so consider lowering its value |
| 772 | if fewer speakers are detected than are actually present in your sound. |
| 773 | |
| 774 | ##Segmentation step (0-1)# (standard value: 0.1) |
| 775 | : the distance between the starts of consecutive overlapping analysis windows, as a fraction of |
| 776 | the analysis window’s length. The sound is analysed in 10-second overlapping segments called |
| 777 | %%analysis windows%; because of the overlap, each moment in time is covered by several |
| 778 | analysis windows. A smaller segmentation step ensures more analysis windows with more overlap, |
| 779 | which is generally more accurate but takes longer. A larger segmentation step ensures fewer |
| 780 | windows with less overlap, which is faster but generally less accurate. You may try |
| 781 | increasing this value if you want diarization to run faster, but it’s best to keep it below 0.5 |
| 782 | so that every moment in the sound is covered by at least two analysis windows. |
| 783 | |
| 784 | Algorithm |
| 785 | ========= |
| 786 | The algorithm is a port of @@pyannote.audio@’s `pyannote/speaker-diarization-3.1` pipeline (see |
| 787 | @@Bredin (2023)@) with some adaptations. It has four stages. |
| 788 | |
| 789 | ##1. Segmentation#. The sound is divided into overlapping 10-second %%analysis windows%. The |
| 790 | distance between the starts of two consecutive windows is defined by the ##Segmentation step |
| 791 | (0-1)# as a fraction of the window length. For example, a segmentation step of 0.1 makes this |
| 792 | distance 1 second, so that consecutive windows have a 90\% overlap. |
| 793 | |
| 794 | The sound from each analysis window is then sent to the %%segmentation model%, which divides it |
| 795 | into 589 frames (each frame spanning approximately 17 milliseconds) and assigns a label to each |
| 796 | frame in the following way: |
| 797 | - the model assumes that there are at most three speakers in one analysis window, of whom at most |
| 798 | two can be active in each frame; |
| 799 | - for every frame, the model computes a 7-dimensional vector of probabilities for the following |
| 800 | combinations of active speakers: {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}; |
| 801 | - the most probable combination is then taken as that frame’s label. |
| 802 | |
| 803 | The speaker numbers 1, 2 and 3 are local to each analysis window: speaker 1 in one window is not |
| 804 | necessarily the same person as speaker 1 in another. Mapping the window-local speakers to the |
| 805 | global ones is the task of stages 2 and 3. |
| 806 | |
| 807 | ##2. Speaker embeddings#. %Embedding is a term used in the field of machine learning which inherited |
| 808 | it from mathematics. In machine learning, an %embedding is a specific kind of representation of an |
| 809 | object as a vector in a space of many dimensions (or, in other words, a point in that space), |
| 810 | chosen in such a way that vectors representing similar objects end up close to each other. The object |
| 811 | is thus %embedded into a multidimensional space, and the resulting vector is itself called an |
| 812 | %embedding. What is an “object” and what counts as “similar” depends on the task; here an object is |
| 813 | a sound, and two sounds are considered similar if the same person is speaking in them. |
| 814 | |
| 815 | The previous stage determined which speaker is active in which frame (for every analysis window). |
| 816 | Now, for each window and each local speaker in this window (1, 2 or 3), the frames are found where |
| 817 | this speaker is active. For example, speaker 1 is active in the frames where at least one of the |
| 818 | combinations {1}, {1, 2} or {1, 3} from stage 1 had non-zero probability. Then, for each window and |
| 819 | each speaker active somewhere in it, the frames where this speaker is active are glued together into |
| 820 | a single sound, which is then sent to the %%embedding model%. For every such sound, this model |
| 821 | produces an %embedding: a 256-dimensional vector representing one particular speaker in one |
| 822 | particular analysis window. The embeddings of the same speaker (from different analysis windows) |
| 823 | tend to be closer to each other than the embeddings of different speakers. This makes the next |
| 824 | stage possible. |
| 825 | |
| 826 | ##3. Clustering#. The previous stage produces one embedding for each active speaker in each |
| 827 | analysis window (so, up to three embeddings per window). The embeddings that are backed by |
| 828 | enough non-overlapping speech are considered to be “reliable” and are used in the clustering |
| 829 | process; the others are set aside for now. |
| 830 | |
| 831 | The reliable embeddings from all analysis windows are first L2-normalized so that they are all |
| 832 | located on a 256-dimensional unit hypersphere. They are then grouped using %%agglomerative |
| 833 | hierarchical clustering with centroid linkage%. Grouping starts with each embedding forming its |
| 834 | own group (with the centre of the group being the embedding itself). At each step, the two groups |
| 835 | whose centres are the closest (as measured by Euclidean distance between them) are merged, and |
| 836 | the centre of the newly formed group is the mean of all the embeddings in this group. This centre |
| 837 | is not L2-normalized, therefore the centres of merged groups lie inside the 256-dimensional |
| 838 | hypersphere and become slightly shorter with every merge. This process stops when the distance |
| 839 | between the next two closest groups is larger than the ##Clustering threshold (0-2)#. |
| 840 | |
| 841 | Because the embeddings are L2-normalized, the distance between any two of them lies between 0 |
| 842 | (identical) and 2 (opposite), which explains the range of possible values for the clustering |
| 843 | threshold. |
| 844 | |
| 845 | Each final group represents one speaker; if after reaching the threshold there are still more groups |
| 846 | than ##Max. number of speakers (≥ 2)#, the merging continues until the resulting number of groups |
| 847 | does not exceed that maximum. |
| 848 | |
| 849 | Finally, the unreliable embeddings (those not used to form the groups) are attached to their |
| 850 | nearest groups. In this way, each window-local speaker is assigned to a global speaker. |
| 851 | |
| 852 | The two figures below show an example of the clustering process for four embeddings in a |
| 853 | two-dimensional space. Each group centre is drawn as a solid arrow surrounded by a grey circle whose |
| 854 | radius is the clustering threshold (here 0.7, the default). Two groups can be merged only if |
| 855 | both their centres lie inside each other’s grey circles (or, in other words, if they are closer |
| 856 | than the clustering threshold). |
| 857 | |
| 858 | The ##left figure# shows the initial four group centres (the same as the four embeddings). The |
| 859 | closest two group centres are drawn in red; these groups are merged first. The next merge |
| 860 | involves the groups with the next two closest centres (those drawn in blue). The ##right figure# |
| 861 | shows the state after the two merges: the solid arrows are the centres of the two newly formed |
| 862 | groups; the dotted arrows are the original embeddings making up each group. Now, neither of the |
| 863 | two group centres lies inside the grey circle surrounding the other one. So the two groups are |
| 864 | further apart than the clustering threshold; therefore, the clustering process stops, leaving |
| 865 | these two groups as the final result. |
| 866 | |
| 867 | {- 5.5x3 |
| 868 | b1 = 35 |
| 869 | b2 = 75 |
| 870 | r1 = 235 |
| 871 | r2 = 245 |
| 872 | b1x = cos(b1*pi/180) |
| 873 | b1y = sin(b1*pi/180) |
| 874 | b2x = cos(b2*pi/180) |
| 875 | b2y = sin(b2*pi/180) |
| 876 | r1x = cos(r1*pi/180) |
| 877 | r1y = sin(r1*pi/180) |
| 878 | r2x = cos(r2*pi/180) |
| 879 | r2y = sin(r2*pi/180) |
| 880 | threshold = 0.7 |
| 881 | |
| 882 | # ==== LEFT ======== |
| 883 | Select inner viewport: 0, 2.5, 0.25, 2.75 |
| 884 | Axes: -1.5, 1.5, -1.5, 1.5 |
| 885 | Solid line |
| 886 | |
| 887 | # thresholds |
| 888 | Line width: 0.6 |
| 889 | Colour: "Grey" |
| 890 | Paint circle: 0.9, b1x, b1y, threshold |
| 891 | Paint circle: 0.9, b2x, b2y, threshold |
| 892 | Paint circle: 0.9, r1x, r1y, threshold |
| 893 | Paint circle: 0.9, r2x, r2y, threshold |
| 894 | Draw circle: b1x, b1y, threshold |
| 895 | Draw circle: b2x, b2y, threshold |
| 896 | Draw circle: r1x, r1y, threshold |
| 897 | Draw circle: r2x, r2y, threshold |
| 898 | |
| 899 | # axes |
| 900 | Line width: 1 |
| 901 | Colour: "Grey" |
| 902 | Draw line: -1.3, 0, 1.3, 0 |
| 903 | Draw line: 0, -1.3, 0, 1.3 |
| 904 | Text special: 1.03, "left", 0, "bottom", "Times", 10, "0", "1" |
| 905 | Text special: -1.03, "right", 0, "bottom", "Times", 10, "0", "\-m1" |
| 906 | Text special: 0.03, "left", 1.01, "bottom", "Times", 10, "0", "1" |
| 907 | Text special: -0.03, "right", -1.02, "top", "Times", 10, "0", "\-m1" |
| 908 | |
| 909 | # unit hypersphere |
| 910 | Line width: 2 |
| 911 | Colour: "Black" |
| 912 | Draw circle: 0, 0, 1 |
| 913 | |
| 914 | # blue vectors |
| 915 | Colour: "Blue" |
| 916 | Line width: 2 |
| 917 | Draw arrow: 0.0, 0.0, b1x, b1y |
| 918 | Draw arrow: 0.0, 0.0, b2x, b2y |
| 919 | |
| 920 | # red vectors |
| 921 | Colour: "Red" |
| 922 | Line width: 2 |
| 923 | Draw arrow: 0.0, 0.0, r1x, r1y |
| 924 | Draw arrow: 0.0, 0.0, r2x, r2y |
| 925 | |
| 926 | # ==== RIGHT ======== |
| 927 | b3x = (b1x + b2x) / 2 |
| 928 | b3y = (b1y + b2y) / 2 |
| 929 | r3x = (r1x + r2x) / 2 |
| 930 | r3y = (r1y + r2y) / 2 |
| 931 | |
| 932 | Select inner viewport: 3, 5.5, 0.25, 2.75 |
| 933 | Axes: -1.5, 1.5, -1.5, 1.5 |
| 934 | Solid line |
| 935 | |
| 936 | # thresholds |
| 937 | Line width: 0.6 |
| 938 | Colour: "Grey" |
| 939 | Paint circle: 0.9, b3x, b3y, threshold |
| 940 | Paint circle: 0.9, r3x, r3y, threshold |
| 941 | Draw circle: b3x, b3y, threshold |
| 942 | Draw circle: r3x, r3y, threshold |
| 943 | |
| 944 | # axes |
| 945 | Line width: 1 |
| 946 | Colour: "Grey" |
| 947 | Draw line: -1.3, 0, 1.3, 0 |
| 948 | Draw line: 0, -1.3, 0, 1.3 |
| 949 | Text special: 1.03, "left", 0, "bottom", "Times", 10, "0", "1" |
| 950 | Text special: -1.03, "right", 0, "bottom", "Times", 10, "0", "\-m1" |
| 951 | Text special: 0.03, "left", 1.01, "bottom", "Times", 10, "0", "1" |
| 952 | Text special: -0.03, "right", -1.02, "top", "Times", 10, "0", "\-m1" |
| 953 | |
| 954 | # unit hypersphere |
| 955 | Line width: 2 |
| 956 | Colour: "Black" |
| 957 | Draw circle: 0, 0, 1 |
| 958 | |
| 959 | # blue vectors |
| 960 | Dotted line |
| 961 | Colour: "Blue" |
| 962 | Line width: 1 |
| 963 | Draw arrow: 0.0, 0.0, b1x, b1y |
| 964 | Draw arrow: 0.0, 0.0, b2x, b2y |
| 965 | Solid line |
| 966 | Line width: 2 |
| 967 | Draw arrow: 0.0, 0.0, b3x, b3y |
| 968 | |
| 969 | # red vectors |
| 970 | Dotted line |
| 971 | Colour: "Red" |
| 972 | Line width: 1 |
| 973 | Draw arrow: 0.0, 0.0, r1x, r1y |
| 974 | Draw arrow: 0.0, 0.0, r2x, r2y |
| 975 | Solid line |
| 976 | Line width: 2 |
| 977 | Draw arrow: 0.0, 0.0, r3x, r3y |
| 978 | } |
| 979 | |
| 980 | ##4. Reconstruction#. At stage 1, each analysis window was divided into 589 frames of |
| 981 | approximately 17 milliseconds, and each window-frame received a 7-dimensional vector with |
| 982 | probabilities of different combinations of local speakers being active. Because the analysis |
| 983 | windows overlap, each frame on the global timeline is covered by several windows. The goal of |
| 984 | the current stage is to combine the window-frame information across all covering windows, using the |
| 985 | local-to-global speaker mapping established at stage 3. |
| 986 | |
| 987 | Using the 7-dimensional vectors from stage 1, for each speaker in each window-frame, %%soft |
| 988 | activations% are computed, by adding together the probabilities of all combinations in which that |
| 989 | speaker is active. This is a number between 0 and 1 (where 0 means definitely silent and 1 means |
| 990 | definitely active). These local speakers’ soft activations are then attributed to the global |
| 991 | speakers using the mapping from stage 3. After that they are averaged across all the covering |
| 992 | windows, to produce an %%average activation% for each global speaker in each global frame. |
| 993 | |
| 994 | Separately, the number of simultaneously active speakers in each global frame is found in a |
| 995 | similar way. Each window-frame had a winning combination of active speakers (the frame label from |
| 996 | stage 1), containing 0, 1 or 2 speakers. For each global frame, this number is averaged across |
| 997 | all covering windows, rounded, and capped at 1 when ##Allow speakers to overlap# is off. The |
| 998 | resulting number determines how many speakers (those with the highest average activations) are |
| 999 | marked active in this frame. |
| 1000 | |
| 1001 | Finally, for each speaker, every uninterrupted sequence of frames in which that speaker is active |
| 1002 | becomes one %segment. The result is a list of segments, where each segment is attributed to one |
| 1003 | speaker. |
| 1004 | |
| 1005 | Availability in Praat |
| 1006 | ===================== |
| 1007 | For diarization as part of transcription, see @@transcription with whisper.cpp@. |
| 1008 | |
| 1009 | Standalone diarization is available in two ways: |
| 1010 | - if you select a @Sound together with its @TextGrid and choose |
| 1011 | @@TextGrid & Sound: Diarize interval...|Diarize interval...@; |
| 1012 | - via ##Diarize interval# from the #Interval menu in the @TextGridEditor. The settings for this |
| 1013 | command are set via ##Diarization settings...# in the same menu and are remembered across Praat |
| 1014 | sessions. |
| 1015 | |
| 1016 | ################################################################################ |
| 1017 | "TextGrid & Sound: Diarize interval..." |
| 1018 | © Anastasia Shchupak 2026-06-01 |
| 1019 | |
| 1020 | This command takes a specified interval of the @TextGrid, runs diarization on the corresponding part |
| 1021 | of the @Sound, and writes the result back into the TextGrid. The labels of the intervals are |
| 1022 | specified by the settings ##Non-speech interval label# and ##Speech interval label#. |
| 1023 | |
| 1024 | Settings |
| 1025 | ======== |
| 1026 | ##Tier number |
| 1027 | : the number of the tier containing the interval to be diarized. |
| 1028 | |
| 1029 | ##Interval number |
| 1030 | : the number of the interval to be diarized. |
| 1031 | |
| 1032 | ##Max. number of speakers (≥ 2)# (standard value: 2) |
| 1033 | : see @@speaker diarization with adapted pyannote.audio@. |
| 1034 | |
| 1035 | ##Allow speakers to overlap# (standard: on) |
| 1036 | : see @@speaker diarization with adapted pyannote.audio@. |
| 1037 | |
| 1038 | ##Clustering threshold (0-2)# (standard value: 0.7) |
| 1039 | : see @@speaker diarization with adapted pyannote.audio@. |
| 1040 | |
| 1041 | ##Segmentation step (0-1)# (standard value: 0.1) |
| 1042 | : see @@speaker diarization with adapted pyannote.audio@. |
| 1043 | |
| 1044 | ##Non-speech interval label# (standard value: “”) |
| 1045 | : the label assigned to intervals classified as non-speech in the resulting TextGrid. |
| 1046 | |
| 1047 | ##Speech interval label# (standard value: “speech”) |
| 1048 | : the label assigned to intervals classified as speech in the resulting TextGrid. |
| 1049 | |
| 1050 | ################################################################################ |
| 1051 | "SpeechRecognizer" |
| 1052 | © Anastasia Shchupak 2026-03-15 |
| 1053 | |
| 1054 | One of the @@types of objects@ in Praat. It performs @@transcription with whisper.cpp@ on a |
| 1055 | @Sound object. If you are new to speech recognition in Praat, see the @@Speech recognition@ |
| 1056 | tutorial first. |
| 1057 | |
| 1058 | Commands |
| 1059 | ======== |
| 1060 | |
| 1061 | Creation: |
| 1062 | , @@Create SpeechRecognizer...@ |
| 1063 | |
| 1064 | Transcription: |
| 1065 | , @@SpeechRecognizer & Sound: Transcribe@ |
| 1066 | |
| 1067 | ################################################################################ |
| 1068 | "Create SpeechRecognizer..." |
| 1069 | © Anastasia Shchupak 2026-03-15 |
| 1070 | |
| 1071 | Creates the @SpeechRecognizer object. |
| 1072 | If you are new to speech recognition in Praat, see the @@Speech recognition@ tutorial first. |
| 1073 | |
| 1074 | Settings |
| 1075 | ======== |
| 1076 | ##Whisper model |
| 1077 | ##Language |
| 1078 | : for both settings see @@transcription with whisper.cpp@. |
| 1079 | |
| 1080 | ################################################################################ |
| 1081 | "SpeechRecognizer & Sound: Transcribe" |
| 1082 | © Anastasia Shchupak 2026-03-15 |
| 1083 | |
| 1084 | @@transcription with whisper.cpp|Transcribes@ selected @Sound using selected @SpeechRecognizer |
| 1085 | object and writes the result of transcription to the @@Info window@. |
| 1086 | |
| 1087 | The sound is automatically resampled to 16 kHz (the sampling frequency expected by @@whisper.cpp@) |
| 1088 | before being processed. |
| 1089 | |
| 1090 | The transcription uses the @@speech activity detection with Silero VAD@ built into @@whisper.cpp@ |
| 1091 | to skip non-speech parts of the sound, which improves both speed and accuracy. |
| 1092 | |
| 1093 | The result is a flat text string containing the full transcription. |
| 1094 | |
| 1095 | ################################################################################ |
| 1096 | "Silero VAD" |
| 1097 | © Anastasia Shchupak 2026-06-01 |
| 1098 | |
| 1099 | Silero VAD is a pre-trained speech activity detector created by Silero Team; see |
| 1100 | @@Silero Team (2024)@ for the model and documentation. VAD stands for “voice activity detection”, |
| 1101 | but we use “speech activity detection” instead, because Silero VAD detects unvoiced parts of speech |
| 1102 | as well as voiced parts. The Silero VAD model is compiled into Praat (see @Acknowledgments). |
| 1103 | |
| 1104 | For how Silero VAD is used in Praat, as well as its algorithm and settings, see @@speech activity |
| 1105 | detection with Silero VAD@. |
| 1106 | |
| 1107 | ################################################################################ |
| 1108 | "whisper.cpp" |
| 1109 | © Anastasia Shchupak 2026-06-01 |
| 1110 | |
| 1111 | Whisper is an automatic speech recognition (ASR) system by OpenAI for transcribing speech |
| 1112 | into text; see @@Radford et al. (2022)@ for the model architecture, training and evaluation. |
| 1113 | OpenAI’s Whisper implementation is in Python (PyTorch). |
| 1114 | |
| 1115 | Praat uses whisper.cpp, a lightweight C/C++ port of Whisper built on top of the ggml tensor library |
| 1116 | for machine learning, developed by Georgi Gerganov and many other contributors (see |
| 1117 | @Acknowledgments). The original OpenAI Whisper models must be converted to ggml format for use with |
| 1118 | whisper.cpp. |
| 1119 | |
| 1120 | For how transcription is used in Praat, see the @@Speech recognition@ tutorial. |
| 1121 | For the transcription settings, see @@transcription with whisper.cpp@. |
| 1122 | |
| 1123 | ################################################################################ |
| 1124 | "pyannote.audio" |
| 1125 | © Anastasia Shchupak 2026-06-01 |
| 1126 | |
| 1127 | pyannote.audio is an automatic speaker diarization toolkit developed by Hervé Bredin and |
| 1128 | collaborators (see @@Plaquet & Bredin (2023)@ and @@Bredin (2023)@). |
| 1129 | |
| 1130 | Praat contains a C++/ggml adaptation of its `pyannote/speaker-diarization-3.1` pipeline. |
| 1131 | The pipeline uses two neural models: `pyannote/segmentation-3.0` by pyannote.audio for segmentation |
| 1132 | and `wespeaker-voxceleb-resnet34-LM` by @@WeSpeaker@ for speaker embedding. |
| 1133 | The `pyannote/segmentation-3.0` weights have been converted to ggml format |
| 1134 | and embedded into Praat (see @Acknowledgments). |
| 1135 | |
| 1136 | For how speaker diarization is used in Praat, see the @@Speech recognition@ tutorial. |
| 1137 | For the diarization settings, see @@speaker diarization with adapted pyannote.audio@. |
| 1138 | |
| 1139 | ################################################################################ |
| 1140 | "WeSpeaker" |
| 1141 | © Anastasia Shchupak 2026-06-01 |
| 1142 | |
| 1143 | WeSpeaker is a speaker embedding learning toolkit developed by WeNet Community |
| 1144 | (see @@Wang et al. (2023)@ and @@Wang et al. (2024)@). Praat uses one of its pretrained models, |
| 1145 | the `wespeaker-voxceleb-resnet34-LM` embedding model, as part of @@pyannote.audio@’s |
| 1146 | `pyannote/speaker-diarization-3.1` pipeline. |
| 1147 | |
| 1148 | `wespeaker-voxceleb-resnet34-LM` was trained on the VoxCeleb2 dataset |
| 1149 | (see @@Chung, Nagrani & Zisserman (2018)@ and @@Nagrani, Chung & Zisserman (2017)@). |
| 1150 | The model weights have been converted to ggml format and embedded into Praat (see @Acknowledgments). |
| 1151 | Praat contains a C++/ggml port of WeSpeaker’s ResNet34 architecture with TSTP pooling, |
| 1152 | used for inference on this model. |
| 1153 | |
| 1154 | ################################################################################ |
| 1155 | "Silero Team (2024)" |
| 1156 | © Anastasia Shchupak 2026-06-01 |
| 1157 | |
| 1158 | Silero Team (2024). Silero VAD: pre-trained enterprise-grade voice activity detector (VAD), |
| 1159 | number detector and language classifier [Computer software]. Version 6.2.0. |
| 1160 | |
| 1161 | Available on `https://github.com/snakers4/silero-vad`. |
| 1162 | |
| 1163 | ################################################################################ |
| 1164 | "Radford et al. (2022)" |
| 1165 | © Anastasia Shchupak 2026-06-01 |
| 1166 | |
| 1167 | Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey & Ilya Sutskever (2022): |
| 1168 | “Robust speech recognition via large-scale weak supervision.” |
| 1169 | |
| 1170 | Available on `https://cdn.openai.com/papers/whisper.pdf`. |
| 1171 | |
| 1172 | ################################################################################ |
| 1173 | "Plaquet & Bredin (2023)" |
| 1174 | © Anastasia Shchupak 2026-06-01 |
| 1175 | |
| 1176 | Alexis Plaquet & Hervé Bredin (2023): “Powerset multi-class cross entropy loss for neural |
| 1177 | speaker diarization.” %%Proc. Interspeech 2023%. |
| 1178 | |
| 1179 | Available on `https://www.isca-archive.org/interspeech_2023/plaquet23_interspeech.html`. |
| 1180 | |
| 1181 | ################################################################################ |
| 1182 | "Bredin (2023)" |
| 1183 | © Anastasia Shchupak 2026-06-01 |
| 1184 | |
| 1185 | Hervé Bredin (2023): “pyannote.audio 2.1 speaker diarization pipeline: principle, benchmark, |
| 1186 | and recipe.” %%Proc. Interspeech 2023%. |
| 1187 | |
| 1188 | Available on `https://www.isca-archive.org/interspeech_2023/bredin23_interspeech.html`. |
| 1189 | |
| 1190 | ################################################################################ |
| 1191 | "Wang et al. (2023)" |
| 1192 | © Anastasia Shchupak 2026-06-01 |
| 1193 | |
| 1194 | Hongji Wang, Chengdong Liang, Shuai Wang, Zhengyang Chen, Binbin Zhang, Xu Xiang, Yanlei Deng |
| 1195 | & Yanmin Qian (2023): “Wespeaker: a research and production oriented speaker embedding learning |
| 1196 | toolkit.” %%ICASSP 2023 - 2023 IEEE International Conference on Acoustics, Speech and Signal |
| 1197 | Processing (ICASSP)%, 1–5. |
| 1198 | |
| 1199 | Available on `https://doi.org/10.48550/arXiv.2210.17016`. |
| 1200 | |
| 1201 | ################################################################################ |
| 1202 | "Wang et al. (2024)" |
| 1203 | © Anastasia Shchupak 2026-06-01 |
| 1204 | |
| 1205 | Shuai Wang, Zhengyang Chen, Bing Han, Hongji Wang, Chengdong Liang, Binbin Zhang, Xu Xiang, |
| 1206 | Wen Ding, Johan Rohdin, Anna Silnova, Yanmin Qian & Haizhou Li (2024): “Advancing speaker |
| 1207 | embedding learning: Wespeaker toolkit for research and production.” %%Speech Communication% |
| 1208 | ##162#: 103104. |
| 1209 | |
| 1210 | Available on `https://doi.org/10.1016/j.specom.2024.103104`. |
| 1211 | |
| 1212 | ################################################################################ |
| 1213 | "Chung, Nagrani & Zisserman (2018)" |
| 1214 | © Anastasia Shchupak 2026-06-01 |
| 1215 | |
| 1216 | Joon Son Chung, Arsha Nagrani & Andrew Zisserman (2018): “VoxCeleb2: deep speaker recognition.” |
| 1217 | %%Proc. Interspeech 2018%. |
| 1218 | |
| 1219 | Available on `https://www.isca-archive.org/interspeech_2018/chung18b_interspeech.html`. |
| 1220 | |
| 1221 | ################################################################################ |
| 1222 | "Nagrani, Chung & Zisserman (2017)" |
| 1223 | © Anastasia Shchupak 2026-06-01 |
| 1224 | |
| 1225 | Arsha Nagrani, Joon Son Chung & Andrew Zisserman (2017): “VoxCeleb: a large-scale speaker |
| 1226 | identification dataset.” %%Proc. Interspeech 2017%. |
| 1227 | |
| 1228 | Available on `https://www.isca-archive.org/interspeech_2017/nagrani17_interspeech.html`. |
| 1229 | |
| 1230 | ################################################################################ |
| 1231 | )~~~" |
| 1232 | MAN_PAGES_ENDcxx . . $ `sys/ManPagesM.h:28:9`! |
| 1233 | |
| 1234 | } |
| 1235 | |
| 1236 | /* End of file manual_SpeechRecognizer.cpp */ |