DEV Community

Cover image for Day 14: Youtube Voice Search with Python
Dilek Karasoy for Picovoice

Posted on

Day 14: Youtube Voice Search with Python

Have you ever been in a situation where you are going back and forth in a YouTube video. podcast or a movie searching for a specific phrase? No more. Meet OctoTube: It's like Google Search for entire YouTube video content, not just text-based keywords

Get Started
Clone the Octopus GitHub repository:

git clone --recurse-submodules https://github.com/Picovoice/octopus.git
Enter fullscreen mode Exit fullscreen mode

Run this from the root of the repository to install Python dependencies:

pip3 install -r demo/youtube/requirements.txt
Enter fullscreen mode Exit fullscreen mode

It's day 14, you probably have your AccessKey but if not get your AccessKey from Picovoice Console

Find a video on YouTube you like to search and from the root of the repository run:

python3 demo/youtube/octotube.py \
--access-key ${ACCESS_KEY} \
--url ${YOUTUBE_VIDEO_URL} \
--phrases ${SEARCH_PHRASE0} ${SEARCH_PHRASE1}
Enter fullscreen mode Exit fullscreen mode

You should get something like the below

indexed 3024 seconds of audio in 54.36 seconds
searched 3024 seconds of audio for 1 phrases in 0.01013 seconds
pied piper >>>
[0.5] https://www.youtube.com/watch?v=Lt6PPiTTwbE&t=784
[1.0] https://www.youtube.com/watch?v=Lt6PPiTTwbE&t=840
[1.0] https://www.youtube.com/watch?v=Lt6PPiTTwbE&t=2355
[1.0] https://www.youtube.com/watch?v=Lt6PPiTTwbE&t=2940
Enter fullscreen mode Exit fullscreen mode

Indexing is the bulk of the processing time. The good news is once the video is indexed, it is super fast to search for more.

searched 3024 seconds of audio for 1 phrases in 0.00655 seconds
jian yang >>>
[0.3] https://www.youtube.com/watch?v=Lt6PPiTTwbE&t=1332
[0.7] https://www.youtube.com/watch?v=Lt6PPiTTwbE&t=2478
Enter fullscreen mode Exit fullscreen mode

How Does it Work?
OctoTube uses the Octopus Speech-to-Index engine. Octopus directly indexes audio without relying on a text representation.

Top comments (0)