Skip to content
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

Silly script: BBC world service streaming text #185

Closed
semiformal-net opened this issue Nov 26, 2022 · 6 comments
Closed

Silly script: BBC world service streaming text #185

semiformal-net opened this issue Nov 26, 2022 · 6 comments
Labels
ideas Interesting ideas for experimentation

Comments

@semiformal-net
Copy link
Contributor

Thanks for the code! This is great!

This script will:

  1. grab 30s of audio from bbc radio
  2. transcribe it
  3. spit out transcribed text
  4. repeat

bbc_blaster.sh

#!/bin/bash
for i in $(seq 0 5); do
    ffmpeg -y -i "http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_world_service.m3u8" -ar 16000 -ac 1 -c:a pcm_s16le -t 30s /tmp/bbcws0.wav > /dev/null 2> /tmp/radioerr &
    PID=( $PID $! )
    wait
    mv /tmp/bbcws0.wav /tmp/bbcws.wav
    ./main -t 8 -m ./models/ggml-base.en.bin -f /tmp/bbcws.wav --no-timestamps -otxt > /dev/null 2> /tmp/whispererr &
    cat /tmp/bbcws.wav.txt
    echo
done

Which looks like this...

$ ./bbc_blaster.sh 
 - Something special about the Crescent crane, you weren't supposed to play with the eat or harm eat. Then when you go to school, you learn about the national symbols and understand the importance. People tend to, for instance, name their businesses after eat, schools, shops, hospitals. The national football team, for instance, the national netball team are all named after the crane. - So you were taught about the Crescent crane
 would. So you would see them practically everywhere. But their population is in decline. Tell us why. The population is in decline because especially in southwestern Uganda, which is largely a very, very green mountainous area. It also tended to have a lot of wetland or swampland areas. And these birds breed in swampland areas. They find food in low-lying valleys. As the population has continued to grow.
 green, mountainous area. It also tended to have a lot of wetland or swampland areas. And these birds breed in swampland areas. They find food in low-lying valleys. As the population has continued to grow all across the country, of course, but more particularly in southwestern Uganda, there has been degradation of the environment. People are looking for more and more land where to settle, more and more land where to grow.
 in low-lying valleys, as the population has continued to grow all across the country, of course, but more particularly in southwestern Uganda, there has been degradation of the environment. People are looking for more and more land where to settle, more and more land where to grow food. And as such, they drain swampland because they have water underneath. The farms do really well, of course, then that means that they are destroying.
 are looking for more and more land where to settle, more and more land where to grow food. And as such, they drain swampland because they have water underneath. The farms do really well. Of course, then that means that they are destroying the habitat of these birds. And patients, you went to Southwest Uganda to meet a man who is actually trying to save these iconic birds. Tell us about him. His name is Jimmy Muhozim.
 - It is well, of course, then that means that they are destroying the habitat of these birds. - And patients, you went to Southwest Uganda to meet a man who is actually trying to save these iconic birds. Tell us about him. - His name is Jimmy Mujozi Muhebua. He's an environmental scientist and he works for an organization called Nature Uganda. So what they are trying to do is work with local communities and try and give--
@ggerganov ggerganov added the ideas Interesting ideas for experimentation label Nov 26, 2022
@ggerganov
Copy link
Owner

ggerganov commented Nov 26, 2022

@semiformal-net
Great idea :) I think this is exactly what @abelbabel was looking for in #65 (comment)

I added the livestream.sh script to the repo. It is based on your idea above.
For example:

cd whisper.cpp
make

# transcribe BBC radio stream using small.en at 10s chunks
./examples/livestream.sh http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_world_service.m3u8 10000 small.en

There is a problem that across sequential ffmpeg runs, we loose a bit of audio so some of the words are missing.
Not sure how to fix this. Probably there is some ffmpeg to solve this.

@semiformal-net
Copy link
Contributor Author

@ggerganov glad I could help!

I noticed the loss of audio between snapshots as well... I'll play around with ffmpeg and see if I can figure out a patch.

@abelbabel
Copy link

abelbabel commented Nov 26, 2022

In the result it may become what I was looking for, but I would consider this a workaround ... to me it seems kind of breaking how one expects unix-programs usually work - when getting data via pipe, process it ...

Maybe the approach might be to adapt the stream example and generalize it (where one example/specific use case is reading from mic-device and another might be reading from pipe ...) ... in fact it should make no difference, if input to the command is a mic or an ffmpeg-stream or whatever, as long as it has the wav-format

@ggerganov
Copy link
Owner

@abelbabel

You can actually already achieve something very similar to what you describe:

  • create a loopback capture device that feeds the speakers output back as input
  • run the stream example using the --capture N argument, where N is the id of the loopback capture device
  • you then play your audio as you normally would do (i.e. using ffplay, vlc, etc) - the stream app will capture it through the loopback device and transcribe it as if it was piped

@semiformal-net
Copy link
Contributor Author

I created PR #195 that is a bit better. It seems to eliminate the lost words between clips with new logic

@ggerganov
Copy link
Owner

Continued in #209

anandijain pushed a commit to anandijain/whisper.cpp that referenced this issue Apr 28, 2023
jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this issue Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ideas Interesting ideas for experimentation
Projects
None yet
Development

No branches or pull requests

3 participants