0:00.240–0:05.920
Can the open AI whisper model dostreaming ASR? My name is Bai. I'm a
0:05.920–0:12.000
chine learning engineer and a PhD inatural language processing. And today Iwill answer this question. So if you
0:12.000–0:19.840
haven't seen the whisper model, it is aspeechtoext model. It is trained onabout 100 languages on 680,000 hours of
0:19.840–0:27.279
data. The model architecture is aencoder decoder transformer model and itcomes in five different sizes and it is
0:27.279–0:33.520
growing in popularity recently becauseit is robust to noise and accents. Sothe question of the day is can this
0:33.520–0:40.320
model do streaming speech recognition.So first of all what do we mean bystreaming ASR? Well, automated speech
0:40.320–0:46.320
recognition can come in two forms batchand streaming. Batch means that themodel needs to take a bunch of speech
0:46.320–0:57.680
and produce a bunch of text. Butstreaming ASR is when the model needs toproduce an output as the speaker isaying things with a delay of not more
0:57.680–1:04.960
than a few seconds. So for example, ifyou're listening to a live broadcast,you don't want to first record the
1:04.960–1:12.400
ntire broadcast and then produce thesubtitles, you want it to appear at mosta few seconds after it is said. And
1:12.400–1:19.840
generally you'll expect streaming ASR tobe a few percentage points loweraccuracy than batch ASR because the
1:19.840–1:27.040
model does not have access to all thecontext only the point up until thecurrent word. The question of how to do
1:27.040–1:35.840
streaming ASR came up when I wasbuilding the voice writer. This is an AIwriting assistant that works in twosteps. In the first step, you just speak
1:35.840–1:41.680
your thoughts without worrying too muchabout the grammar. And in the secondstep, the AI corrects the grammar for
1:41.680–1:47.920
you. I've been finding it super helpfulfor writing all kinds of things,including emails, blog posts, and Slack
1:47.920–1:54.560
messages. You can try it out for free inthe link here. And I'll also post a linkin the description of the video. Now,
1:54.560–1:59.600
back to the video. First of all, why isthis even difficult? Why is it not so
1:59.600–2:04.719
easy to use the Whisper model forstreaming ASR? The issue is Whisper is
2:04.719–2:12.640
trained to process input audio of 30seconds long. If the audio is less than30 seconds, you can pad it to be longer.
2:12.640–2:20.080
So, this is not too much of a problem.But what if your audio is longer than 30seconds? There is no way to feed into
2:20.080–2:26.560
Whisper anything longer than 30 seconds.So, the first thing you might think ofis what if you just split it up into
2:26.560–2:33.680
chunks of 30 seconds at a time andprocess each chunk one at a time. Well,the first problem is you might split it
2:33.680–2:42.160
in the middle of the word. Like if yousplit it while in the middle of theword, this word will probably not berecognized correctly. The second problem
2:42.160–2:49.120
is the latency will be really high. Soimagine if you're processing audio,you're waiting for audio to fill up
2:49.120–2:57.519
these 30 seconds and only then will youprocess this entire chunk and then thelatency um for for the first word will
2:57.519–3:05.120
be up to 30 seconds. Fortunately, thereis an open source report called WhisperStreaming that does this for you and it
3:05.120–3:13.519
urns the Whisper model into a streamingASR system. There are instructions onhow to set this up. So, let's try it
3:13.519–3:21.120
out. So, I run this command to start amodel running um it's using a whispersmall model and then I go to this tab
3:21.120–3:30.000
and run another command and I just startspeaking. So you can pretty quickly seethat it's um picking it up and it's
3:30.000–3:37.519
pretty quick and responsive and it evengives timestamps. So um it's pretty cooldemo. Um now let's talk about how this
3:37.519–3:46.319
works. So we start with this audio fileand what we do is we feed chunks ofincreasing size into whisper. The size
3:46.319–3:54.879
of these chunks is configured by theminimum chunk size parameter which bydefault is 1 second. So in eachiteration, we increase the size of this
3:54.879–4:02.560
buffer by 1 second and feed all of itinto whisper. And this process continuesuntil we hit a end of sentence marker
4:02.560–4:09.680
like a period or a question mark. Thenwe move the buffer forward and start theprocess again. So each piece of audio is
4:09.680–4:16.079
processed by whisper multiple times asmany times as it takes until we hit thend of the sentence. The reasons for
4:16.079–4:22.960
this is whisper is trained on sentences.So, it gives the best result when thestart of the audio aligns with the start
4:22.960–4:29.680
of a sentence. And that's why the bufferonly moves forward when the previousentence is complete and we're beginning
4:29.680–4:35.520
a new sentence. This way, Whisper neverneeds to start transcribing from themiddle of a sentence, which would give
4:35.520–4:42.320
suboptimal results. In manyapplications, it is useful to have someresults available as soon as possible,
4:42.320–4:48.960
even if they're not completely accurate.In the voice writer, I am showing theincomplete results in gray whereas the
4:48.960–4:57.120
confirmed results are in black. Thedifference is the gray part of thesentence is unconfirmed. So it maychange as the model gets new
4:57.120–5:07.520
information. But the black part is theconfirmed results and they arepermanent. How this works is using analgorithm called local agreement with n
5:07.520–5:14.720
equals 2. This means that for a token tobe confirmed, it needs to be generatedin two consecutive audio buffers. Let's
5:14.720–5:22.320
give an example. Let's say in the firstep, the worst per model outputs thethree tokens if you like and nothing is
5:22.320–5:28.960
confirmed at this step. In the secondstep, the model produces more tokens,but only the first two tokens agree with
5:28.960–5:36.000
e previous step. So those two areconfirmed. In the third and the fourthsteps, more tokens are generated. But at
5:36.000–5:44.320
each step, it does not confirm anytokens until it is at least generated intwo consecutive chunks. So anything in
5:44.320–5:53.280
the gray part is possible to change andgiven new information. For example, theword view might change to video once the
5:53.280–6:00.160
model hears the rest of the sentence.But anything in the black part ispermanent. So even if the model wants to
6:00.160–6:07.120
change it to something else after moreiterations it cannot be changed anymore.One last thing that this model does when
6:07.120–6:15.039
it generates a new sentence is it feedsthe previous sentence into the model asprompt tokens. So this is something that
6:15.039–6:22.000
you can do in the whisper format is youcan give it a bunch of prompt tokensbefore you start generating and this
6:22.000–6:28.720
tends to improve the accuracy a littlebit because more context is always good.So in summary, the algorithm can be
6:28.720–6:37.360
summarized in three basic ideas. Thefirst idea is we feed longer and longerconsecutive audio buffers into whisper
6:37.360–6:45.280
and then we emit tokens as soon asthey're confirmed by two iterations. Andfinally, we scroll forward the audio
6:45.280–6:52.400
buffer whenever a sentence is completed.So, it's a pretty simple algorithm thatyou can apply to any speech to text
6:52.400–6:58.720
model that does not support streamingand basically turn it into a streamingmodel. If you like, you can check out
6:58.720–7:05.039
all the details in this paper, whichI'll link in the description. One of thelimitations comes from the fact that
7:05.039–7:12.479
whisper was not really designed to be astreaming model. And because of this, itassumes that each audio buffer has to
7:12.479–7:18.400
start at the beginning of a sentence.Therefore, if you have a sentence thatis quite long, then the beginning of the
7:18.400–7:27.280
sentence has to be fed into the modeland processed many times. This isinefficient and not necessary if themodel was trained from the beginning to
7:27.280–7:36.080
do streaming ASR. Now, if we look at anarchitecture that was designedspecifically to do streaming speechrecognition, it looks a little bit
7:36.080–7:46.319
different. Here is a model that wasproposed in 2021. At each step, itpredicts a token and it has access to afixed amount of past context and future
7:46.319–7:53.199
context. During training, this rule isenforced by having an intention maskthat is mostly zeros, meaning that the
7:53.199–8:00.080
model cannot use information that isoutside of this fixed window. And duringprediction, the model predicts a token
8:00.080–8:07.360
given a limited amount of fixed context.To make the next prediction, the entireceptive field moves forward by one
8:07.360–8:13.759
chunk, but the size of the receptivefield is fixed. This way, the beginningof the sentence will not be processed
8:13.759–8:20.240
multiple times. However, this is notpossible with the whisper model becauseit requires modifying the architecture
8:20.240–8:26.560
and retraining the model and we do nothave access to whisper's training data.That's it for this video and I hope you
8:26.560–8:33.279
enjoyed my explanation of how Whispercan be turned into a streaming model. Ifyou enjoyed this video, please leave a
8:33.279–8:41.000
comment, hit the subscribe button, andring the bell icon to stay notified whenI release future videos. Goodbye.
0:00.240–0:05.920
開放式AI的Whisper模型能進行串流語音辨識嗎?我叫白,是一名
0:05.920–0:12.000
機器學習工程師,擁有自然語言處理博士學位。今天我將回答這個問題。所以如果你
0:12.000–0:19.840
還沒看過Whisper模型,它是一個語音轉文字模型。它是在約100種語言、68萬小時的
0:19.840–0:27.279
數據上訓練而成的。模型架構是編碼器-解碼器Transformer模型,它有五種不同的尺寸,最近
0:27.279–0:33.520
因為對噪音和口音具有魯棒性而日益受歡迎。所以今天的问题是,這個
0:33.520–0:40.320
模型能進行串流語音辨識嗎?首先,什麼是串流語音辨識?自動語音
0:40.320–0:46.320
辨識可以分為兩種形式:批次和串流。批次意味著模型需要接收一堆語音
0:46.320–0:57.680
並產生一堆文字。但串流語音辨識是指模型需要在說話者說話的同時產生輸出,延遲不超過
0:57.680–1:04.960
幾秒鐘。例如,如果你正在收聽現場直播,你不想先錄下整場
1:04.960–1:12.400
直播再產生字幕,你希望它在說出的幾秒後就出現。而且
1:12.400–1:19.840
通常你會預期串流語音辨識的準確率比批次語音辨識低幾個百分點,因為
1:19.840–1:27.040
模型無法取得所有上下文,只能取得直到當前詞彙為止的點。關於如何進行
1:27.040–1:35.840
串流語音辨識的問題,是在我開發Voice Writer時出現的。這是一個AI
1:35.840–1:41.680
寫作助手,分兩步運作。第一步,你只需說出你的想法,不用太擔心
1:41.680–1:47.920
語法。第二步,AI會幫你修正語法。我發現它對撰寫各種內容都非常有幫助,
1:47.920–1:54.560
包括電子郵件、部落格文章和Slack訊息。你可以透過這裡的連結免費試用。我也會在影片描述中附上連結。現在,
1:54.560–1:59.600
回到影片。首先,為什麼這很困難?為什麼不容易
1:59.600–2:04.719
使用Whisper模型進行串流語音辨識?問題在於Whisper是
2:04.719–2:12.640
為了處理長達30秒的輸入音訊而訓練的。如果音訊少於30秒,你可以填充使其更長。
2:12.640–2:20.080
所以,這不算太大問題。但如果你的音訊超過30秒怎麼辦?無法將
2:20.080–2:26.560
超過30秒的內容輸入Whisper。所以,你可能會想到的第一件事是,如果將其分割成
2:26.560–2:33.680
每次30秒的區塊並逐一處理每個區塊會怎樣?嗯,第一個問題是你可能會在
2:33.680–2:42.160
單字中間分割。例如,如果你在單字中間分割,這個單字可能無法被正確辨識。第二個問題
2:42.160–2:49.120
是延遲會非常高。所以想象一下,如果你正在處理音訊,你需要等待音訊填滿
2:49.120–2:57.519
這些 30 秒的片段,然後才處理整個片段,接著延遲對於第一個單詞來說
2:57.519–3:05.120
可能會高達30秒。幸運的是,有一個開源報告稱為WhisperStreaming,它可以為你完成這項工作,並將
3:05.120–3:13.519
Whisper模型轉換為串流語音辨識系統。這裡有設置說明。所以,讓我們試試看
3:13.519–3:21.120
吧。所以我執行這個命令來啟動模型運行,它使用的是Whisper small模型,然後我進入這個標籤
3:21.120–3:30.000
並執行另一個命令,我開始說話。所以你可以很快地看到它
3:30.000–3:37.519
相當快速且具回應性,甚至還提供時間戳記。所以這是一個很酷的示範。嗯,現在讓我們討論它是如何運作的。所以我們從這個音訊檔案開始,我們的做法是將大小逐漸增加的區塊輸入Whisper。這些區塊的大小由最小區塊大小參數配置,預設為1秒。所以在每次迭代中,我們將這個緩衝區的大小增加1秒,並將所有內容輸入Whisper。這個過程持續進行,直到我們遇到句號或問號等句子結束標記。然後我們將緩衝區向前移動,並重新開始這個過程。所以每段音訊都會被Whisper多次處理,直到我們遇到句子結束為止。這樣做的原因是
3:37.519–3:46.319
運作。所以我們從這個音訊檔案開始,我們的做法是將大小遞增的片段輸入 Whisper。大小
3:46.319–3:54.879
這些片段的大小由最小片段大小參數配置,預設為 1 秒。所以在每次迭代中,我們增加這個
3:54.879–4:02.560
緩衝區的大小 1 秒,並將所有內容輸入 Whisper。這個過程持續進行,直到我們遇到句號或問號等句子結束標記
4:02.560–4:09.680
然後我們將緩衝區向前移動,並重新開始這個過程。因此,每段音訊
4:09.680–4:16.079
會被 Whisper 多次處理,次數取決於直到我們遇到句子結束標記為止。原因在於
4:16.079–4:22.960
Whisper是在句子上訓練的。所以,當音訊的開始與句子的開始對齊時,它會給出最佳結果。這就是為什麼緩衝區只在上一個句子完成且我們開始
4:22.960–4:29.680
新句子時才向前移動。這樣,Whisper永遠不需要從句子中間開始轉錄,這會給出
4:29.680–4:35.520
新句子。這樣,Whisper 永遠不需要從句子中間開始轉錄,這會導致
4:35.520–4:42.320
即使它們不完全準確。在Voice Writer中,我顯示不完整的結果為灰色,而
4:42.320–4:48.960
即使它們不完全準確。在 Voice Writer 中,我將不完整的結果顯示為灰色,而
4:48.960–4:57.120
確認的結果以黑色顯示。差異在於句子的灰色部分尚未確認,因此可能會隨著模型獲得新資訊而改變。
4:57.120–5:07.520
但黑色部分是已確認的結果,它們是永久性的。其運作方式是使用一種稱為「局部一致性(local agreement)」且 n 等於 2 的演算法。
5:07.520–5:14.720
這意味著對於一個 token 要獲得確認,它必須在兩個連續的音訊緩衝區中都被生成。讓我們
5:14.720–5:22.320
舉個例子。假設在第一個步驟中,模型輸出了三個 token「如果你喜歡」,且此步驟中沒有任何內容
5:22.320–5:28.960
獲得確認。在第二個步驟中,模型生成了更多 token,但只有前兩個 token 與
5:28.960–5:36.000
前一個步驟一致。因此這兩個獲得確認。在第三和第四個步驟中,生成了更多 token。但在
5:36.000–5:44.320
每個步驟中,它不會確認任何 token,直到該 token 至少在兩個連續的區塊中被生成。因此,任何在
5:44.320–5:53.280
灰色部分的內容都有可能隨著新資訊而改變。例如,一旦模型
5:53.280–6:00.160
聽到句子的其餘部分,「view」一詞可能會變成「video」。但黑色部分的任何內容都是
6:00.160–6:07.120
永久性的。因此,即使模型在更多迭代後想將其更改為其他內容,也無法再進行更改。這個模型在生成新句子時做的最後一件事是,它將前一個句子作為提示 token 輸入模型。所以這是
6:07.120–6:15.039
在 Whisper 格式中你可以做到的一件事,你可以在開始生成之前提供一堆提示 token,而這
6:15.039–6:22.000
通常會稍微提高準確性,因為更多的上下文總是好的。總而言之,該演算法可以
6:22.000–6:28.720
歸納為三個基本概念。第一個概念是我們將越來越長的連續音訊緩衝區輸入 Whisper,
6:28.720–6:37.360
然後一旦 token 經過兩次迭代確認就立即輸出它們。最後,當句子完成時,我們會向前滾動音訊
6:37.360–6:45.280
緩衝區。因此,這是一個相當簡單的演算法,你可以將其應用於任何不支援串流的語音轉文字
6:45.280–6:52.400
模型,並基本上將其轉變為串流模型。如果你喜歡,你可以查看
6:52.400–6:58.720
這篇論文中的所有詳細資訊,我會在描述中提供連結。其中一個限制來自於
6:58.720–7:05.039
Whisper 並非真正設計為串流模型的事實。正因為如此,它假設每個音訊緩衝區必須
7:05.039–7:12.479
從句子的開頭開始。因此,如果你有一個相當長的句子,那麼句子的開頭必須
7:12.479–7:18.400
被輸入模型並多次處理。這是不高效的,如果模型從一開始就接受訓練以進行
7:18.400–7:27.280
串流語音辨識,則是不必要的。現在,如果我們查看專門為串流語音辨識設計的架構,它看起來會
7:27.280–7:36.080
有些不同。這裡有一個在 2021 年提出的模型。在每個步驟中,它預測一個 token,並且可以存取固定數量的過去上下文和未來
7:36.080–7:46.319
上下文。在訓練期間,這個規則透過擁有一個主要是零的意圖遮罩來強制執行,這意味著
7:46.319–7:53.199
模型無法使用此固定視窗之外的資訊。在預測期間,模型根據有限的固定上下文預測一個 token。為了進行下一個預測,整個感受野向前移動一個
7:53.199–8:00.080
區塊,但感受野的大小是固定的。這樣,句子的開頭就不會被
8:00.080–8:07.360
在給定有限且固定的上下文下,為了進行下一個預測,整個感受野會向前移動一個區塊
8:07.360–8:13.759
但感受野的大小是固定的。這樣做可以避免句子開頭的部分被處理
8:13.759–8:20.240
並重新訓練模型,而我們無法存取 Whisper 的訓練數據。這個影片就到這裡,我希望你
8:20.240–8:26.560
喜歡我關於如何將 Whisper 轉變為串流模型的解釋。如果你喜歡這個影片,請留下
8:26.560–8:33.279
評論,點擊訂閱按鈕,並點擊鈴鐺圖示,以便在我發布未來影片時收到通知。再見。
8:33.279–8:41.000
留言、訂閱按鈕,並點擊鈴鐺圖示,以便在我發布未來影片時收到通知。再見。
0:00.240–0:05.920
Can the open AI whisper model dostreaming ASR? My name is Bai. I'm a
開放式AI的Whisper模型能進行串流語音辨識嗎?我叫白,是一名
0:05.920–0:12.000
chine learning engineer and a PhD inatural language processing. And today Iwill answer this question. So if you
機器學習工程師,擁有自然語言處理博士學位。今天我將回答這個問題。所以如果你
0:12.000–0:19.840
haven't seen the whisper model, it is aspeechtoext model. It is trained onabout 100 languages on 680,000 hours of
還沒看過Whisper模型,它是一個語音轉文字模型。它是在約100種語言、68萬小時的
0:19.840–0:27.279
data. The model architecture is aencoder decoder transformer model and itcomes in five different sizes and it is
數據上訓練而成的。模型架構是編碼器-解碼器Transformer模型,它有五種不同的尺寸,最近
0:27.279–0:33.520
growing in popularity recently becauseit is robust to noise and accents. Sothe question of the day is can this
因為對噪音和口音具有魯棒性而日益受歡迎。所以今天的问题是,這個
0:33.520–0:40.320
model do streaming speech recognition.So first of all what do we mean bystreaming ASR? Well, automated speech
模型能進行串流語音辨識嗎?首先,什麼是串流語音辨識?自動語音
0:40.320–0:46.320
recognition can come in two forms batchand streaming. Batch means that themodel needs to take a bunch of speech
辨識可以分為兩種形式:批次和串流。批次意味著模型需要接收一堆語音
0:46.320–0:57.680
and produce a bunch of text. Butstreaming ASR is when the model needs toproduce an output as the speaker isaying things with a delay of not more
並產生一堆文字。但串流語音辨識是指模型需要在說話者說話的同時產生輸出,延遲不超過
0:57.680–1:04.960
than a few seconds. So for example, ifyou're listening to a live broadcast,you don't want to first record the
幾秒鐘。例如,如果你正在收聽現場直播,你不想先錄下整場
1:04.960–1:12.400
ntire broadcast and then produce thesubtitles, you want it to appear at mosta few seconds after it is said. And
直播再產生字幕,你希望它在說出的幾秒後就出現。而且
1:12.400–1:19.840
generally you'll expect streaming ASR tobe a few percentage points loweraccuracy than batch ASR because the
通常你會預期串流語音辨識的準確率比批次語音辨識低幾個百分點,因為
1:19.840–1:27.040
model does not have access to all thecontext only the point up until thecurrent word. The question of how to do
模型無法取得所有上下文,只能取得直到當前詞彙為止的點。關於如何進行
1:27.040–1:35.840
streaming ASR came up when I wasbuilding the voice writer. This is an AIwriting assistant that works in twosteps. In the first step, you just speak
串流語音辨識的問題,是在我開發Voice Writer時出現的。這是一個AI
1:35.840–1:41.680
your thoughts without worrying too muchabout the grammar. And in the secondstep, the AI corrects the grammar for
寫作助手,分兩步運作。第一步,你只需說出你的想法,不用太擔心
1:41.680–1:47.920
you. I've been finding it super helpfulfor writing all kinds of things,including emails, blog posts, and Slack
語法。第二步,AI會幫你修正語法。我發現它對撰寫各種內容都非常有幫助,
1:47.920–1:54.560
messages. You can try it out for free inthe link here. And I'll also post a linkin the description of the video. Now,
包括電子郵件、部落格文章和Slack訊息。你可以透過這裡的連結免費試用。我也會在影片描述中附上連結。現在,
1:54.560–1:59.600
back to the video. First of all, why isthis even difficult? Why is it not so
回到影片。首先,為什麼這很困難?為什麼不容易
1:59.600–2:04.719
easy to use the Whisper model forstreaming ASR? The issue is Whisper is
使用Whisper模型進行串流語音辨識?問題在於Whisper是
2:04.719–2:12.640
trained to process input audio of 30seconds long. If the audio is less than30 seconds, you can pad it to be longer.
為了處理長達30秒的輸入音訊而訓練的。如果音訊少於30秒,你可以填充使其更長。
2:12.640–2:20.080
So, this is not too much of a problem.But what if your audio is longer than 30seconds? There is no way to feed into
所以,這不算太大問題。但如果你的音訊超過30秒怎麼辦?無法將
2:20.080–2:26.560
Whisper anything longer than 30 seconds.So, the first thing you might think ofis what if you just split it up into
超過30秒的內容輸入Whisper。所以,你可能會想到的第一件事是,如果將其分割成
2:26.560–2:33.680
chunks of 30 seconds at a time andprocess each chunk one at a time. Well,the first problem is you might split it
每次30秒的區塊並逐一處理每個區塊會怎樣?嗯,第一個問題是你可能會在
2:33.680–2:42.160
in the middle of the word. Like if yousplit it while in the middle of theword, this word will probably not berecognized correctly. The second problem
單字中間分割。例如,如果你在單字中間分割,這個單字可能無法被正確辨識。第二個問題
2:42.160–2:49.120
is the latency will be really high. Soimagine if you're processing audio,you're waiting for audio to fill up
是延遲會非常高。所以想象一下,如果你正在處理音訊,你需要等待音訊填滿
2:49.120–2:57.519
these 30 seconds and only then will youprocess this entire chunk and then thelatency um for for the first word will
這些 30 秒的片段,然後才處理整個片段,接著延遲對於第一個單詞來說
2:57.519–3:05.120
be up to 30 seconds. Fortunately, thereis an open source report called WhisperStreaming that does this for you and it
可能會高達30秒。幸運的是,有一個開源報告稱為WhisperStreaming,它可以為你完成這項工作,並將
3:05.120–3:13.519
urns the Whisper model into a streamingASR system. There are instructions onhow to set this up. So, let's try it
Whisper模型轉換為串流語音辨識系統。這裡有設置說明。所以,讓我們試試看
3:13.519–3:21.120
out. So, I run this command to start amodel running um it's using a whispersmall model and then I go to this tab
吧。所以我執行這個命令來啟動模型運行,它使用的是Whisper small模型,然後我進入這個標籤
3:21.120–3:30.000
and run another command and I just startspeaking. So you can pretty quickly seethat it's um picking it up and it's
並執行另一個命令,我開始說話。所以你可以很快地看到它
3:30.000–3:37.519
pretty quick and responsive and it evengives timestamps. So um it's pretty cooldemo. Um now let's talk about how this
相當快速且具回應性,甚至還提供時間戳記。所以這是一個很酷的示範。嗯,現在讓我們討論它是如何運作的。所以我們從這個音訊檔案開始,我們的做法是將大小逐漸增加的區塊輸入Whisper。這些區塊的大小由最小區塊大小參數配置,預設為1秒。所以在每次迭代中,我們將這個緩衝區的大小增加1秒,並將所有內容輸入Whisper。這個過程持續進行,直到我們遇到句號或問號等句子結束標記。然後我們將緩衝區向前移動,並重新開始這個過程。所以每段音訊都會被Whisper多次處理,直到我們遇到句子結束為止。這樣做的原因是
3:37.519–3:46.319
works. So we start with this audio fileand what we do is we feed chunks ofincreasing size into whisper. The size
運作。所以我們從這個音訊檔案開始,我們的做法是將大小遞增的片段輸入 Whisper。大小
3:46.319–3:54.879
of these chunks is configured by theminimum chunk size parameter which bydefault is 1 second. So in eachiteration, we increase the size of this
這些片段的大小由最小片段大小參數配置,預設為 1 秒。所以在每次迭代中,我們增加這個
3:54.879–4:02.560
buffer by 1 second and feed all of itinto whisper. And this process continuesuntil we hit a end of sentence marker
緩衝區的大小 1 秒,並將所有內容輸入 Whisper。這個過程持續進行,直到我們遇到句號或問號等句子結束標記
4:02.560–4:09.680
like a period or a question mark. Thenwe move the buffer forward and start theprocess again. So each piece of audio is
然後我們將緩衝區向前移動,並重新開始這個過程。因此,每段音訊
4:09.680–4:16.079
processed by whisper multiple times asmany times as it takes until we hit thend of the sentence. The reasons for
會被 Whisper 多次處理,次數取決於直到我們遇到句子結束標記為止。原因在於
4:16.079–4:22.960
this is whisper is trained on sentences.So, it gives the best result when thestart of the audio aligns with the start
Whisper是在句子上訓練的。所以,當音訊的開始與句子的開始對齊時,它會給出最佳結果。這就是為什麼緩衝區只在上一個句子完成且我們開始
4:22.960–4:29.680
of a sentence. And that's why the bufferonly moves forward when the previousentence is complete and we're beginning
新句子時才向前移動。這樣,Whisper永遠不需要從句子中間開始轉錄,這會給出
4:29.680–4:35.520
a new sentence. This way, Whisper neverneeds to start transcribing from themiddle of a sentence, which would give
新句子。這樣,Whisper 永遠不需要從句子中間開始轉錄,這會導致
4:35.520–4:42.320
suboptimal results. In manyapplications, it is useful to have someresults available as soon as possible,
即使它們不完全準確。在Voice Writer中,我顯示不完整的結果為灰色,而
4:42.320–4:48.960
even if they're not completely accurate.In the voice writer, I am showing theincomplete results in gray whereas the
即使它們不完全準確。在 Voice Writer 中,我將不完整的結果顯示為灰色,而
4:48.960–4:57.120
confirmed results are in black. Thedifference is the gray part of thesentence is unconfirmed. So it maychange as the model gets new
確認的結果以黑色顯示。差異在於句子的灰色部分尚未確認,因此可能會隨著模型獲得新資訊而改變。
4:57.120–5:07.520
information. But the black part is theconfirmed results and they arepermanent. How this works is using analgorithm called local agreement with n
但黑色部分是已確認的結果,它們是永久性的。其運作方式是使用一種稱為「局部一致性(local agreement)」且 n 等於 2 的演算法。
5:07.520–5:14.720
equals 2. This means that for a token tobe confirmed, it needs to be generatedin two consecutive audio buffers. Let's
這意味著對於一個 token 要獲得確認,它必須在兩個連續的音訊緩衝區中都被生成。讓我們
5:14.720–5:22.320
give an example. Let's say in the firstep, the worst per model outputs thethree tokens if you like and nothing is
舉個例子。假設在第一個步驟中,模型輸出了三個 token「如果你喜歡」,且此步驟中沒有任何內容
5:22.320–5:28.960
confirmed at this step. In the secondstep, the model produces more tokens,but only the first two tokens agree with
獲得確認。在第二個步驟中,模型生成了更多 token,但只有前兩個 token 與
5:28.960–5:36.000
e previous step. So those two areconfirmed. In the third and the fourthsteps, more tokens are generated. But at
前一個步驟一致。因此這兩個獲得確認。在第三和第四個步驟中,生成了更多 token。但在
5:36.000–5:44.320
each step, it does not confirm anytokens until it is at least generated intwo consecutive chunks. So anything in
每個步驟中,它不會確認任何 token,直到該 token 至少在兩個連續的區塊中被生成。因此,任何在
5:44.320–5:53.280
the gray part is possible to change andgiven new information. For example, theword view might change to video once the
灰色部分的內容都有可能隨著新資訊而改變。例如,一旦模型
5:53.280–6:00.160
model hears the rest of the sentence.But anything in the black part ispermanent. So even if the model wants to
聽到句子的其餘部分,「view」一詞可能會變成「video」。但黑色部分的任何內容都是
6:00.160–6:07.120
change it to something else after moreiterations it cannot be changed anymore.One last thing that this model does when
永久性的。因此,即使模型在更多迭代後想將其更改為其他內容,也無法再進行更改。這個模型在生成新句子時做的最後一件事是,它將前一個句子作為提示 token 輸入模型。所以這是
6:07.120–6:15.039
it generates a new sentence is it feedsthe previous sentence into the model asprompt tokens. So this is something that
在 Whisper 格式中你可以做到的一件事,你可以在開始生成之前提供一堆提示 token,而這
6:15.039–6:22.000
you can do in the whisper format is youcan give it a bunch of prompt tokensbefore you start generating and this
通常會稍微提高準確性,因為更多的上下文總是好的。總而言之,該演算法可以
6:22.000–6:28.720
tends to improve the accuracy a littlebit because more context is always good.So in summary, the algorithm can be
歸納為三個基本概念。第一個概念是我們將越來越長的連續音訊緩衝區輸入 Whisper,
6:28.720–6:37.360
summarized in three basic ideas. Thefirst idea is we feed longer and longerconsecutive audio buffers into whisper
然後一旦 token 經過兩次迭代確認就立即輸出它們。最後,當句子完成時,我們會向前滾動音訊
6:37.360–6:45.280
and then we emit tokens as soon asthey're confirmed by two iterations. Andfinally, we scroll forward the audio
緩衝區。因此,這是一個相當簡單的演算法,你可以將其應用於任何不支援串流的語音轉文字
6:45.280–6:52.400
buffer whenever a sentence is completed.So, it's a pretty simple algorithm thatyou can apply to any speech to text
模型,並基本上將其轉變為串流模型。如果你喜歡,你可以查看
6:52.400–6:58.720
model that does not support streamingand basically turn it into a streamingmodel. If you like, you can check out
這篇論文中的所有詳細資訊,我會在描述中提供連結。其中一個限制來自於
6:58.720–7:05.039
all the details in this paper, whichI'll link in the description. One of thelimitations comes from the fact that
Whisper 並非真正設計為串流模型的事實。正因為如此,它假設每個音訊緩衝區必須
7:05.039–7:12.479
whisper was not really designed to be astreaming model. And because of this, itassumes that each audio buffer has to
從句子的開頭開始。因此,如果你有一個相當長的句子,那麼句子的開頭必須
7:12.479–7:18.400
start at the beginning of a sentence.Therefore, if you have a sentence thatis quite long, then the beginning of the
被輸入模型並多次處理。這是不高效的,如果模型從一開始就接受訓練以進行
7:18.400–7:27.280
sentence has to be fed into the modeland processed many times. This isinefficient and not necessary if themodel was trained from the beginning to
串流語音辨識,則是不必要的。現在,如果我們查看專門為串流語音辨識設計的架構,它看起來會
7:27.280–7:36.080
do streaming ASR. Now, if we look at anarchitecture that was designedspecifically to do streaming speechrecognition, it looks a little bit
有些不同。這裡有一個在 2021 年提出的模型。在每個步驟中,它預測一個 token,並且可以存取固定數量的過去上下文和未來
7:36.080–7:46.319
different. Here is a model that wasproposed in 2021. At each step, itpredicts a token and it has access to afixed amount of past context and future
上下文。在訓練期間,這個規則透過擁有一個主要是零的意圖遮罩來強制執行,這意味著
7:46.319–7:53.199
context. During training, this rule isenforced by having an intention maskthat is mostly zeros, meaning that the
模型無法使用此固定視窗之外的資訊。在預測期間,模型根據有限的固定上下文預測一個 token。為了進行下一個預測,整個感受野向前移動一個
7:53.199–8:00.080
model cannot use information that isoutside of this fixed window. And duringprediction, the model predicts a token
區塊,但感受野的大小是固定的。這樣,句子的開頭就不會被
8:00.080–8:07.360
given a limited amount of fixed context.To make the next prediction, the entireceptive field moves forward by one
在給定有限且固定的上下文下,為了進行下一個預測,整個感受野會向前移動一個區塊
8:07.360–8:13.759
chunk, but the size of the receptivefield is fixed. This way, the beginningof the sentence will not be processed
但感受野的大小是固定的。這樣做可以避免句子開頭的部分被處理
8:13.759–8:20.240
multiple times. However, this is notpossible with the whisper model becauseit requires modifying the architecture
並重新訓練模型,而我們無法存取 Whisper 的訓練數據。這個影片就到這裡,我希望你
8:20.240–8:26.560
and retraining the model and we do nothave access to whisper's training data.That's it for this video and I hope you
喜歡我關於如何將 Whisper 轉變為串流模型的解釋。如果你喜歡這個影片,請留下
8:26.560–8:33.279
enjoyed my explanation of how Whispercan be turned into a streaming model. Ifyou enjoyed this video, please leave a
評論,點擊訂閱按鈕,並點擊鈴鐺圖示,以便在我發布未來影片時收到通知。再見。
8:33.279–8:41.000
comment, hit the subscribe button, andring the bell icon to stay notified whenI release future videos. Goodbye.
留言、訂閱按鈕,並點擊鈴鐺圖示,以便在我發布未來影片時收到通知。再見。