LoginSignup
0
1

More than 3 years have passed since last update.

YouTube, Deepspeech, with Google Colaboratory [testing_0003]

Last updated at Posted at 2021-02-23

deepspeech-0.9.3-models

This version is not backwards compatible with earlier versions.

Chinese language models

deepspeech-0.9.3-models-zh-CN.pbmm
deepspeech-0.9.3-models-zh-CN.tflite
deepspeech-0.9.3-models-zh-CN.scorer
which are under the MPL-2.0 license.

#Chinese language model
import os
from os.path import exists
import wave

!pip install -q deepspeech-gpu==0.9.3 youtube-dl

if not exists('deepspeech-0.9.3-models-zh-CN.pbmm'):
  !wget https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models-zh-CN.pbmm 
if not exists('deepspeech-0.9.3-models-zh-CN.scorer'):
  !wget https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models-zh-CN.scorer

from IPython.display import YouTubeVideo

pre-trained model files

  • pbmm ...for TensorFlow runtime

  • tflite ...for TensorFlow Lite runtime

!apt-get install -qq sox

sox - The Python and Node.JS clients use SoX to resample files to 16kHz.

urltext ='https://youtu.be/cNSq5RdVf28'

Testing Chinese YouTube clip with no auto-subtitle(captions)
'v2ray core在v4.23.2版本之前存在重大安全漏洞,请大家尽快更新'
https://youtu.be/cNSq5RdVf28

from urllib.parse import urlparse, parse_qs

#urltext ='https://www.youtube.com/watch?v=rgXHXldCtdk&t=223s'
args = [urltext]
video_id = ''


def extract_video_id(url):
    query = urlparse(url)
    if query.hostname == 'youtu.be': return query.path[1:]
    if query.hostname in {'www.youtube.com', 'youtube.com'}:
        if query.path == '/watch': return parse_qs(query.query)['v'][0]
        if query.path[:7] == '/embed/': return query.path.split('/')[2]
        if query.path[:3] == '/v/': return query.path.split('/')[2]
    # fail?
    return None

for url in args:
    video_id = (extract_video_id(url))
    print('youtube video_id:',video_id)
YouTubeVideo(video_id)
!rm -rf *.wav
!youtube-dl --extract-audio --audio-format wav --output "extract.%(ext)s" {urltext}
##!apt install ffmpeg ##if you do not have

!ffmpeg -i extract.wav -vn -acodec pcm_s16le -ac 1 -ar 16000 -f wav test.wav

Extract from the video in wav format with the file name extract.wav. Deepspeech seems to support audio with a sampling rate of 16000hz.

ffmpeg_cheatsheet_audio
-codecs          # list codecs
-c:a             # audio codec (-acodec)
-fs SIZE         # limit file size (bytes)
-b:v 1M          # video bitrate (1M = 1Mbit/s)
-b:a 1M          # audio bitrate
-vn              # no video
-aq QUALITY      # audio quality (codec-specific)
-ar 16000        # audio sample rate (hz)
-ac 1            # audio channels (1=mono, 2=stereo)
-an              # no audio
-vol N           # volume (256=normal)

!deepspeech --model deepspeech-0.9.3-models-zh-CN.pbmm --scorer deepspeech-0.9.3-models-zh-CN.scorer --audio test.wav > test.txt

from google.colab import files
files.download('test.txt')
print
三豪欢迎来到朴妮对我是朴妮今天在线报才力看到有一些朋友说据出人靠出现了严重的全漏洞我们打开这个微交的项目然后果然在这里看到了一个性症状态的问题不说关于为四点二三年二然后密码炮到前在的特征识别风险我们打开看下他的人问题的想演致力详细说明了漏洞的理论了什么然后营活影在了多时间然后目前处理的方法这里都有一个比较相继的说明但也可以打开进链接自己去研究一下如潮性质的话提高版本一四為三点二十以上版本呢都进行了一个相应的处理但是这个处理可能是暂时的因为他后续还为个更完善的一个处理方法那件天停爆频的目的的着是每年大家分享一下如果平以经安装了不自前给大家分享的这个学会一脚本的三和固也就是为突然天爱强恩说的死和被国家天爱子看底的画了那个就需要去更新下为突人口更新华林的面令用非常的简单从一季就是用官方给了脚板及行一个更新第二季的就是重启下面突认就可以了阿如果是因在这个视频发布之后安装的脑就是最新版本的了不需更新而因为不了为当中被认就是安装最新版本的建为造那这园位一脚下更新的主要是针对自前的六合一脚本的管理脚本当中没有对不是靠进行更新的居民不这有困添加了一项而更可以随时更新征宝一就说只有以后为突變有了新版本以后的女可以去手动的更新这一部分威尔会放到我的博克里会外链接放到视频的下方而针对这两军面介大家可以直接打开我的不克的链接去复制其可以去官方网站区复制也是可以的好现代给大生演戏下具体先回一九本更新了哪一次性或联常安装交本的回叶后我们把六和互承高贴过来用场回车到收取安装下引进力输入与美以后点击回车那这里不仅安装过开底了所以我就开进安装了然后脑图装网站就随意永乐从这里说检测到年一间安装了为突然如果帝之前安装过的话一定要重庆安装因为影响更新到期版本的场人靠大案要做现状这一经提示微突线二三年三一家安装了很开始路口碑的说他还是国二三点二所以作游定要去更新下自己的意所好现在我们已经是最新版本的了这里开低的我们认生成就可了好我们打进的页面也为诗六合一的脚板并没有任何的更新更新的是这一个交派就是他的管理交白我们执行下彩看到致力有一项工更新建置坐那我们直接输入巴插做车不得他就更新到了最新版白好一上就是六回角本的更新能若大家之前使用过滤回一脚板然后人靠不是最新版本的那要即使更进要更新完成以后拿大家还有计的在客户端去即时更新建造好黑天的分享就有这强弱分并喜愛的视频观的多点赞臣想看更多的身兵这个定要的频道同患家

Cf.
Mandarin Speech to Text ; deepspeech test
https://qiita.com/dauuricus/items/eda0cf1d4710f583e7f4

Eg.
deepspeech.ipynb:Testing English Language models & Chinese Language models
https://colab.research.google.com/drive/1I6IgMp5qWA7xRsc1sKJowY3OaW94QwEg?usp=sharing

Comp:
VOSK test_simple.py on GoogleColaboratory [002]

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1