-
Notifications
You must be signed in to change notification settings - Fork 4.2k
vad : add initial Voice Activity Detection (VAD) support #3065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
5758650
to
9f0ed3d
Compare
Are there plans to add vad support for |
I think it would be nice to get an initial version merged first as this PR is quite large as it is. I can then start looking at adding support to the server, and hopefully during that time people can start trying this out and see what works and does not work. I'm adding the remaining options to whisper-cli now and after that this should be ready for review. |
b59768b
to
798695f
Compare
I am doing some initial testing using long audio and I am wondering if we can somehow align the output timestamps with the original audio? Right now, I think that the audio that is cut out is not taken into account, so the final timestamps are not aligned with the input audio and it is a bit difficult to evaluate the results. |
Ah yes, currently what is done is only the samples that are detected to contain speech are passed to With commit the output is now more inline with the original audio input. gb0 without VAD./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/gb0.wav
...
[00:00:00.000 --> 00:00:03.240] Good morning, this Tuesday is Election Day.
[00:00:03.240 --> 00:00:06.000] After months of spirited debate and vigorous campaigning,
[00:00:06.000 --> 00:00:08.640] the time has come for Americans to make important decisions
[00:00:08.640 --> 00:00:10.140] about our nation's future.
[00:00:10.140 --> 00:00:13.740] I encourage all Americans to go to the polls and vote.
[00:00:13.740 --> 00:00:16.140] Election season brings out the spirit of competition
[00:00:16.140 --> 00:00:18.080] between our political parties.
[00:00:18.080 --> 00:00:20.280] And that competition is an essential part
[00:00:20.280 --> 00:00:21.780] of a healthy democracy.
[00:00:21.780 --> 00:00:23.520] But as the campaigns come to a close,
[00:00:23.520 --> 00:00:25.980] Republicans, Democrats, and independents
[00:00:25.980 --> 00:00:29.120] can find common ground on at least one point.
[00:00:29.120 --> 00:00:31.560] Our system of representative democracy
[00:00:31.560 --> 00:00:34.440] is one of America's greatest strengths.
[00:00:34.440 --> 00:00:36.240] The United States was founded on the belief
[00:00:36.240 --> 00:00:38.240] that all men are created equal.
[00:00:38.240 --> 00:00:41.440] Every election day, millions of Americans of all races,
[00:00:41.440 --> 00:00:43.440] religions, and backgrounds step into voting
[00:00:43.440 --> 00:00:45.280] booths throughout the nation.
[00:00:45.280 --> 00:00:47.780] Whether they are rich or poor, old or young,
[00:00:47.780 --> 00:00:50.680] each of them has an equal share in choosing the path
[00:00:50.680 --> 00:00:52.440] that our country will take.
[00:00:52.440 --> 00:00:54.920] And every ballot they cast is a reminder
[00:00:54.920 --> 00:00:58.280] that our founding principles are alive and well.
[00:00:58.280 --> 00:00:59.760] Voting is one of the great privileges
[00:00:59.760 --> 00:01:01.760] of American citizenship.
[00:01:01.760 --> 00:01:04.520] And it has always required brave defenders.
[00:01:04.520 --> 00:01:06.000] As you head to the polls next week,
[00:01:06.000 --> 00:01:08.400] remember the sacrifices that have been made
[00:01:08.400 --> 00:01:11.040] by generations of Americans in uniform
[00:01:11.040 --> 00:01:13.000] to preserve our way of life.
[00:01:13.000 --> 00:01:14.840] From Bunker Hill to Baghdad,
[00:01:14.840 --> 00:01:16.740] the men and women of American armed forces
[00:01:16.740 --> 00:01:19.940] have been devoted guardians of our democracy.
[00:01:19.940 --> 00:01:21.840] All of us owe them and their families
[00:01:21.840 --> 00:01:25.240] a special debt of gratitude on Election Day.
[00:01:25.240 --> 00:01:27.520] Americans should also remember the important example
[00:01:27.520 --> 00:01:30.080] that our election set throughout the world.
[00:01:30.080 --> 00:01:32.080] Young democracies from Georgia and Ukraine
[00:01:32.080 --> 00:01:34.560] to Afghanistan and Iraq can look to the United States
[00:01:34.560 --> 00:01:37.520] for proof that self-government can endure.
[00:01:37.520 --> 00:01:40.400] And nations that still live under tyranny and oppression
[00:01:40.400 --> 00:01:44.080] can find hope and inspiration in our commitment to liberty.
[00:01:44.080 --> 00:01:45.200] For more than two centuries,
[00:01:45.200 --> 00:01:47.120] Americans have demonstrated the ability
[00:01:47.120 --> 00:01:49.600] of free people to choose their own leaders.
[00:01:49.600 --> 00:01:51.880] Our nation has flourished because of its commitment
[00:01:51.880 --> 00:01:54.640] to trusting the wisdom of our citizenry.
[00:01:54.640 --> 00:01:57.200] In this year's election, we will see this tradition
[00:01:57.200 --> 00:02:00.280] continue, and we will be reminded once again
[00:02:00.280 --> 00:02:02.640] that we are blessed to live in a free nation
[00:02:02.640 --> 00:02:05.520] guided by the will of the people.
[00:02:05.520 --> 00:02:06.720] Thank you for listening. gb0 with VAD./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/gb0.wav --vad --vad-threshold 0.5 --vad-model models/for-tests-silero-v5.1.2-ggml.bin
...
[00:00:00.000 --> 00:00:03.280] Good morning, this Tuesday is Election Day.
[00:00:03.280 --> 00:00:06.000] After months of spirited debate and vigorous campaigning,
[00:00:06.000 --> 00:00:08.600] the time has come for Americans to make important decisions
[00:00:08.600 --> 00:00:10.200] about our nation's future.
[00:00:10.200 --> 00:00:13.790] Encourage all Americans to go to the polls and vote.
[00:00:13.790 --> 00:00:16.120] Election season brings out the spirit of competition
[00:00:16.120 --> 00:00:18.060] between our political parties.
[00:00:18.060 --> 00:00:20.230] And that competition is an essential part
[00:00:20.230 --> 00:00:21.820] of a healthy democracy.
[00:00:21.820 --> 00:00:23.550] But as the campaigns come to a close,
[00:00:23.550 --> 00:00:25.960] Republicans, Democrats, and independents
[00:00:25.960 --> 00:00:29.180] can find common ground on at least one point.
[00:00:29.180 --> 00:00:31.530] Our system of representative democracy
[00:00:31.530 --> 00:00:34.470] is one of America's greatest strengths.
[00:00:34.470 --> 00:00:36.250] The United States was founded on the belief
[00:00:36.250 --> 00:00:38.310] that all men are created equal.
[00:00:38.310 --> 00:00:40.740] Every election day, millions of Americans
[00:00:40.740 --> 00:00:42.630] of all races, religions, and backgrounds
[00:00:42.630 --> 00:00:45.340] step into voting booths throughout the nation.
[00:00:45.340 --> 00:00:48.530] Whether they are rich or poor, old or young, each of them
[00:00:48.530 --> 00:00:50.660] has an equal share in choosing the path
[00:00:50.660 --> 00:00:52.480] that our country will take.
[00:00:52.480 --> 00:00:54.910] And every ballot they cast is a reminder
[00:00:54.910 --> 00:00:58.330] that our founding principles are alive and well.
[00:00:58.330 --> 00:00:59.760] Voting is one of the great privileges
[00:00:59.760 --> 00:01:01.810] of American citizenship.
[00:01:01.810 --> 00:01:04.550] And it is always required brave defenders.
[00:01:04.550 --> 00:01:06.050] As you head to the polls next week,
[00:01:06.050 --> 00:01:08.380] remember the sacrifices that have been made
[00:01:08.380 --> 00:01:11.580] by generations of Americans in uniform to preserve
[00:01:11.580 --> 00:01:13.010] our way of life.
[00:01:13.010 --> 00:01:15.450] From Bunker Hill to Baghdad, the men and women
[00:01:15.450 --> 00:01:17.030] of American armed forces have been
[00:01:17.030 --> 00:01:19.990] devoted guardians of our democracy.
[00:01:19.990 --> 00:01:21.790] All of us owe them and their families
[00:01:21.790 --> 00:01:25.260] a special debt of gratitude on election day.
[00:01:25.260 --> 00:01:27.520] Americans should also remember the important example
[00:01:27.520 --> 00:01:30.090] that our elections set throughout the world.
[00:01:30.090 --> 00:01:32.070] Young democracies from Georgia and Ukraine
[00:01:32.070 --> 00:01:34.520] to Afghanistan and Iraq can look to the United States
[00:01:34.520 --> 00:01:37.450] for proof that self-government can endure.
[00:01:37.450 --> 00:01:40.400] And nations that still live under tyranny and oppression
[00:01:40.400 --> 00:01:44.080] can find hope and inspiration in our commitment to liberty.
[00:01:44.080 --> 00:01:45.690] For more than two centuries, Americans
[00:01:45.690 --> 00:01:47.730] have demonstrated the ability of free people
[00:01:47.730 --> 00:01:49.600] to choose their own leaders.
[00:01:49.600 --> 00:01:51.830] Our nation has flourished because of its commitment
[00:01:51.830 --> 00:01:54.630] to trusting the wisdom of our citizenry.
[00:01:54.630 --> 00:01:58.460] In this year's election, we will see this tradition continue.
[00:01:58.460 --> 00:02:00.220] And we will be reminded once again
[00:02:00.220 --> 00:02:02.590] that we are blessed to live in a free nation
[00:02:02.590 --> 00:02:05.490] guided by the will of the people.
[00:02:05.490 --> 00:02:06.650] Thank you for listening.
|
This commit add support for Voice Activity Detection (VAD). When enabled this feature will process the audio input and detect speech segments. This information is then used to reduce the number of samples that need to be processed by whisper_full. This initial support is based on the Silero VAD model which needs to be converted to GGML format: ```console $ (venv) pip install silero-vad $ (venv) $ python models/convert-silero-vad-to-ggml.py --output models/silero.bin Saving GGML Silero-VAD model to models/silero-v5.1.2-ggml.bin ``` There is test the tests the VAD support in isolation: ```console $ cmake --build build --target test-vad && \ ctest -R ^test-vad$ --test-dir build -C Debug --output-on-failure -VV ``` And one that tests VAD in combination with whisper_full: ```console $ cmake --build build --target test-vad-full && \ ctest -R test-vad-full --test-dir build -C Debug --output-on-failure -VV ``` Resolves: ggml-org#3003
Example of format: ```console $ ./build/bin/whisper-cli --help usage: ./build/bin/whisper-cli [options] file0 file1 ... supported audio formats: flac, mp3, ogg, wav options: -h, --help [default] show this help message and exit ... Voice Activity Detection (VAD) options: -v, --vad [false ] enable Voice Activity Detection (VAD) -vm FNAME, --vad-model FNAME [ ] VAD model path -vt N, --vad-threshold N [0.50 ] VAD threshold for speech recognition -vs N, --vad_window_size_samples N [512 ] VAD window size -vspd N, --vad_min_speech_duration_ms N [250 ] VAD min speech duration -vsd N, --vad_min_silence_duration_ms N [100 ] VAD min silence duration -vmsd N, --vad_max_speech_duration_s N [FLT_MAX] VAD max speech duration -vp N, --vad_speech_pad_ms N [30 ] VAD speech padding -vo N, --vad_samples_overlap N [0.10 ] VAD samples overlap size ``` The main reason for the separate VAD options section is that the VAD options are longer and made the rest look a little ugly.
This commit adds a job to the CI pipeline to test the VAD model. This will only test the VAD model in isolation, that is it does not test whisper_full.
This commit adds a mapping of the original audio timestamps to the timestamps of the segments in the VAD (Voice Activity Detection) process. The motivation for this change is when we process the original audio signal and only pass the speech segments to whisper_full, the timestamps that whisper returnes when calling functions like whisper_full_get_segment_t0 are the timestamps for the "VAD" segments and not the original audio. The values are not identical to the the timestamps processed without VAD enabled but they are close, and hopefully close enough.
This commit add support for Voice Activity Detection (VAD). When enabled
this feature will process the audio input and detect speech segments.
This information is then used to reduce the number of samples that need
to be processed by whisper_full.
This initial support is based on the Silero VAD model which needs to be converted to GGML format:
There is test the tests the VAD support in isolation:
And one that tests VAD in combination with whisper_full:
Resolves: #3003
whisper-cli example output