python语音特征提取

In this post, I will show you how to extract speeches from a video recording file. After recognizing the speeches we will convert them into a text document. This will be a simple machine learning project, that will help you to understand some basics of the Google Speech Recognition library. Speech Recognition is a popular topic under machine learning concepts. Speech Recognition is getting used more in many fields. For example, the subtitles that we see on Netflix shows or YouTube videos are created mostly by machines using Artificial Intelligence. Other great examples of speech recognizers are personal voice assistants such as Google’s Home Mini, Amazon Alexa, Apple’s Siri.

在本文中,我将向您展示如何从视频录制文件中提取语音。 识别语音后,我们会将其转换为文本文档。 这将是一个简单的机器学习项目,它将帮助您了解Google语音识别库的一些基础知识。 语音识别是机器学习概念下的热门话题。 语音识别在许多领域得到越来越多的使用。 例如,我们在Netflix节目或YouTube视频上看到的字幕主要是由使用人工智能的机器创建的。 语音识别器的其他出色示例还包括个人语音助手,例如Google的Home Mini,亚马逊的Alexa,苹果的Siri。

目录: (Table of Contents:)

  • Getting Started

    入门

  • Step 1: Import Libraries

    步骤1:导入库

  • Step 2: Video to Audio Conversion

    第2步:视频到音频的转换

  • Step 3: Speech Recognition

    步骤3:语音识别

  • Final Step: Exporting Result

    最后一步:导出结果

Photo by Alexandre Pellaes on Unsplash
亚历山大·佩莱斯 ( Alexandre Pellaes)在Unsplash上摄

入门 (Getting Started)

As you can understand from the title, we will need a video recording for this project. It can even be a recording of yourself speaking to the camera. Using a library called MoviePy, we will extract the audio from the video recording. And in the next step, we will convert that audio file into text using Google’s speech recognition library. If you are ready, let’s get started by installing the libraries!

正如您从标题中所了解的那样,我们将需要此项目的视频记录。 它甚至可以记录您自己对着摄像机讲话。 使用名为MoviePy的库我们将从录像中提取音频。 下一步,我们将使用Google的语音识别库将该音频文件转换为文本。 如果您准备好了,就让我们开始安装这些库!

图书馆 (Libraries)

We are going to use two libraries for this project:

我们将为该项目使用两个库:

  • Speech Recognition语音识别
  • MoviePyMoviePy

Before importing them to our project file, we have to install them. Installing a module library is very easy in python. You can even install a couple of libraries in one line of code. Write the following line in your terminal window:

在将它们导入我们的项目文件之前,我们必须先安装它们。 在python中安装模块库非常容易。 您甚至可以在一行代码中安装几个库。 在您的终端窗口中写以下行:

pip install SpeechRecognition moviepy

Yes, that was it. SpeechRecognition module supports multiple recognition APIs, and Google Speech API is one of them. You can learn more about the module from here.

是的,就是这样。 SpeechRecognition模块支持多种识别API,而Google Speech API就是其中之一。 您可以从此处了解有关该模块的更多信息。

MoviePy is a library that can read and write all the most common audio and video formats, including GIF. If you are having issues when installing moviepy library, try by installing ffmpeg. Ffmpeg is a leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.

MoviePy是一个库,可以读取和写入所有最常见的音频和视频格式,包括GIF。 如果在安装moviepy库时遇到问题,请尝试安装ffmpeg。 Ffmpeg是领先的多媒体框架,能够解码,编码,转码,mux,demux,流,过滤和播放人类和机器创建的几乎所有内容。

Now, we should get to writing code in our code editor. We will start by importing the libraries.

现在,我们应该在代码编辑器中编写代码。 我们将从导入库开始。

第1步-导入库 (Step 1 — Import Libraries)

import speech_recognition as sr import moviepy.editor as mp

Yes, that’s all we need to get the task done. Without losing any time let’s move to the next step.

是的,这就是我们完成任务所需要的。 在不浪费时间的情况下,让我们继续下一步。

步骤2 —视频到音频转换 (Step 2 — Video to Audio Conversion)

In this step, we will something really cool, which is converting our video recording into an audio file. There are many video formats, some of them can be listed as:

在这一步中,我们将做一些非常酷的事情,即将视频记录转换为音频文件。 视频格式很多,其中一些可以列出为:

  • MP4 (mp4, m4a, m4v, f4v, f4a, m4b, m4r, f4b, mov)MP4(mp4,m4a,m4v,f4v,f4a,m4b,m4r,f4b,mov)
  • 3GP (3gp, 3gp2, 3g2, 3gpp, 3gpp2)3GP(3gp,3gp2、3g2、3gpp,3gpp2)
  • OGG (ogg, oga, ogv, ogx)OGG(ogg,oga,ogv,ogx)
  • WMV (wmv, wma, asf*)WMV(WMV,WMA,ASF *)

We should know our video’s format to do the conversion without any problem. Besides the video format, it’s also a good practice to know some audio formats. Here are some of them:

我们应该知道我们视频的格式可以毫无问题地进行转换。 除了视频格式,了解某些音频格式也是一种好习惯。 这里是其中的一些:

  • MP3MP3
  • AACAAC
  • WMAWMA
  • AC3 (Dolby Digital)AC3(杜比数字)

Now, we have some idea about both formats. It’s time to do the conversion using MoviePy library. You will not believe how easy it is.

现在,我们对两种格式都有一些了解。 现在该使用MoviePy库进行转换了。 您不会相信这有多么容易。

clip = mp.VideoFileClip(r”video_recording.mov”) 

clip.audio.write_audiofile(r”converted.wav”)

I recommend converting it to wav format. It works great with the speech recognition library, which will be covered in the next step.

我建议将其转换为WAV格式。 它与语音识别库配合使用非常好,下一步将对此进行介绍。

第3步-语音识别 (Step 3 — Speech Recognition)

First, let’s define the recognizer.

首先,让我们定义识别器。

r = sr.Recognizer()

Now let’s import the audio file that was created in the previous step (Step 2).

现在,让我们导入在上一步(步骤2)中创建的音频文件。

audio = sr.AudioFile("converted.wav")

Perfect! Here comes the best part, which is recognizing the speech in an audio file. The recognizer will try to understand the speech and convert it to a text format.

完善! 这是最好的部分,它是识别音频文件中的语音。 识别器将尝试理解语音并将其转换为文本格式。

with audio as source:  audio_file = r.record(source)result = r.recognize_google(audio_file)

最后一步-导出结果 (Final Step — Exporting the Result)

Well done! The hard work is completed. In this step, we will just export the recognized speech into a text document. This will help you to store your work. I’ve also added a print(“ready!”) at the end of the code. So that we know when the file is ready and the work is completed.

做得好! 艰苦的工作已经完成。 在此步骤中,我们将仅将识别出的语音导出到文本文档中。 这将帮助您存储您的工作。 我还在代码的末尾添加了打印(“ ready!”) 。 这样我们就知道文件何时准备就绪并且工作完成了。

# exporting the result with open('recognized.txt',mode ='w') as file:    file.write("Recognized Speech:")    file.write("\n")    file.write(result)    print("ready!")

视频示范 (Video Demonstration)

Just started my journey on YouTube, I will be demonstrating Machine Learning, Data Science, Artificial Intelligence and more projects for you. Enjoy!

刚开始我在YouTube上的旅程,我将为您演示机器学习,数据科学,人工智能和更多项目。 请享用!

Congrats! You have created a program that converts a video into an audio file and then extracts the speech from that audio. And lastly, exporting the recognized speech into a text document. Hoping that you enjoyed reading this post and working on the project. I am glad if you learned something new today. Working on hands-on programming projects like this one is the best way to sharpen your coding skills.

恭喜! 您已经创建了一个程序,可以将视频转换为音频文件,然后从该音频中提取语音。 最后,将识别的语音导出到文本文档中。 希望您喜欢阅读这篇文章并从事该项目。 如果您今天学到新知识,我感到很高兴。 从事这样的动手编程项目是提高您的编码技能的最佳方法。

Feel free to contact me if you have any questions while implementing the code.

实施代码时如有任何疑问,请随时与我联系 。

Follow my blog and Towards Data Science to stay inspired.

关注我的博客和迈向数据科学 ,保持灵感。

相关内容: (Related Content:)

翻译自: https://towardsdatascience.com/extracting-speech-from-video-using-python-f0ec7e312d38

python语音特征提取


http://www.taodudu.cc/news/show-2938138.html

相关文章:

  • python音频特征提取_Python干货:如何使用Python对音频进行特征提取?
  • 信号完整性(SI)电源完整性(PI)学习笔记(三十四)100条估计信号完整性效应的经验法则
  • 深入理解JVM虚拟机13:JVM面试题,看这篇就足够了(87题详解)
  • 综述:轻量级CNN架构设计
  • PS学习笔记(05)
  • PS2018学习笔记(19-24节)
  • Photoshop基础教程
  • 信号完整性100条经验法则
  • 为什么总学不好PS?300集PS从入门到高级自学教程,全面且系统
  • 一些ps会遇到的问题
  • 100条信号完整性效应的经验法则
  • 学习日记day17 ps
  • 失传万年的PS致富经典(九)
  • 学习日记day09 ps
  • [Win32]画笔和规则区域填充
  • 自媒体视频号博主个人兴趣认证怎么选择?
  • 兴趣爱好页面.html,兴趣筛选页面.html
  • (三)兴趣对于工作的重要性
  • 快速学习COSMIC方法之九:如何识别兴趣对象?
  • 7-90 社交集群 (30分)--详解
  • 2020年海南自贸港大学生职业生涯 规划大赛职业生涯规划书
  • 索要兴趣
  • JAVA个人博客系统毕业设计,个人博客系统设计与实现,个人博客网页设计毕设作品
  • 自学系列 | 就谈兴趣!
  • JAVA--建立一个可输入个人信息的窗口
  • Python+Django+Mysql实现在线音乐推荐系统 基于用户、项目、兴趣标签的协同过滤推荐在线音乐系统、用户兴趣标签推荐系统 代码实现 源代码下载
  • 一个因为兴趣而走上前端开发的程序员
  • 兴趣点推荐代码_如何解读霍兰德职业兴趣测评结果
  • 机器人兴趣班奖状_拼音兴趣班奖状导师寄语
  • VMware Workstation 15 pro 安装macOS 10.13,macOS 10.14教程(仅供个人兴趣学习使用)

python语音特征提取_使用Python从视频中提取语音相关推荐

  1. python 语音特征提取_使用python实现语音文件的特征提取方法

    概述 语音识别是当前人工智能的比较热门的方向,技术也比较成熟,各大公司也相继推出了各自的语音助手机器人,如百度的小度机器人.阿里的天猫精灵等.语音识别算法当前主要是由rnn.lstm.dnn-hmm等 ...

  2. python音频特征提取_使用Python对音频进行特征提取

    写在前面 因为喜欢玩儿音乐游戏,所以打算研究一下如何用深度学习的模型生成音游的谱面.这篇文章主要目的是介绍或者总结一些音频的知识和代码. 恩.如果没玩儿过的话,音乐游戏大概是下面这个样子. 下面进入正 ...

  3. ffmpeg视频中提取语音

    1) conda install ffmpeg pip install ffmpy 2)把mp4转换成AVI import ffmpy ff = ffmpy.FFmpeg(inputs={'IQ.mp ...

  4. 如何提取视频中的语音转换成文字?分享一个超好用的方法

    在现代的数字化时代,视频和音频的使用越来越广泛.但是,当你需要从视频中获取有用的信息时,最好的方法是将视频中的语音转换成文字.这不仅使信息更容易理解,还可以通过搜索引擎和文本编辑器对其进行搜索.在本文 ...

  5. python调用百度语音搜索_使用 Python 和百度语音识别生成视频字幕

    从视频中提取音频 安装 moviepy pip install moviepy 相关代码: audio_file = work_path + '\\out.wav' video = VideoFile ...

  6. python音频 降噪_从视频中提取音频数据,然后应用傅里叶对音频降噪(python)...

    视频准备 QQ有热键 然后随便打开一个视频网站进行录屏 我选择B站 从视频中提取音频 需要安装包moviepy pip install moviepy 提取代码 from moviepy.editor ...

  7. python一帧一帧读取视频_用Python从视频中提取每一帧的图片

    大家应该都有这样的情况:在看到某些视频的画面时感觉美如画,想截取下来却又烦于截图的繁琐,现在我就教大家使用Python提取视频中每一帧的画面,让大家不错过每一个精彩的瞬间! •语言:Python •所 ...

  8. python opencv 录制视频_如何使用OpenCV、Python和深度学习在图像和视频中实现面部识别?...

    Face ID 的兴起带动了一波面部识别技术热潮.本文将介绍如何使用 OpenCV.Python 和深度学习在图像和视频中实现面部识别,以基于深度识别的面部嵌入,实时执行且达到高准确度. 以下内容由 ...

  9. python诞生的时间地点人物事件_教程|计算任意视频中各人物的出镜时间(附Python实现)...

    ,内容略有删改 前言 简介 当我开始接触深度学习时,学到的第一件事就是图像分类.这个话题非常有趣,包括我在内的很多人都沉浸在它的魅力之中.但是在我处理图像分类时总会思考,如果我能将学到的东西迁移到视频 ...

最新文章

  1. c++ int转unsigned int_mysql中int、bigint、smallint 和 tinyint的区别详细介绍
  2. 【页面传值6种方式】- 【JSP 页面传值方法总结:4种】 - 【跨页面传值的几种简单方式3种】...
  3. 如何创建一张表mysql_如何创建一张规范的MySQL表
  4. 南方科技大学-计算智能与先进制造方向-博士-博士后-研究助理招聘
  5. Prefer copy Over retain
  6. 利用Bootstrap Paginator插件和KnockoutJS完成分页功能
  7. 线性代数————思维导图(上岸必备)(二次型)
  8. 虚拟机桥接模式联网设置
  9. DRAM Timing
  10. ASEMI肖特基二极管1N5819压降是什么意思
  11. 毫秒数转换为时间计时天数
  12. 【WiFi】WiFi6E 6G 信道与频宽对应关系
  13. Android项目 moudle和library转换
  14. 《终身成长》读书笔记
  15. 图片转world文档 Excel excel 新
  16. Python开HTTP服务器
  17. Cream Finance 重入漏洞事件分析
  18. 攻防世界-leaking-(详细操作)做题过程
  19. 本地生活服务商家小程序开发解决方案
  20. Android打印机--小票打印格式及模板设置

热门文章

  1. 倒水问题题解(勿喷)
  2. Linux之命令scp远程拷贝文件
  3. Gradle安装部署与基础入门详解
  4. ipynb转py命令
  5. Dynamips和Vmware完成CCVP试验(3)
  6. java中上传本地图片
  7. java Date与 double 互转
  8. Bonferroni校正法
  9. 2021华为软件精英挑战赛(杭厦第20名)
  10. Sentinel @SentinelResource 详解