語音自動轉文字和自動生成字幕

點擊 鏈接看效果

經常生活中有些痛點。比如坐地鐵的時候,如果用耳機看一個沒有字幕的視頻你會很難受,因為雜訊大,你聽不清視頻里說什麼,你也不可能把聲音調的非常大,很傷耳朵。看英語視頻的時候,如果沒有中文字幕,英語水平差,你很難看懂。如果添加英文字幕,有點英語水平的可能能看個大概懂了。日常生活中,你可能有個錄音文件,非常希望自動轉化成文字。

以上的痛點說痛不痛,但如果有工具能自動幫我們做一些語音到文字的自動化工作該有多好啊。根據視頻的語音信息,自動添加字幕youtube很早就有了,而且youtube上可以自動翻譯。如果說句話識別成文字 科大訊飛,百度等有許多的產品。但是將很長的音頻轉成文字或者自動為視頻添加字幕,這樣自動化的軟體並不常見。科大訊飛應該有這樣的軟體,不知道是不是要收錢。

自己是做軟體的,生活中的這些痛點讓自己覺得,不如用已有的資源做個添加字幕或者音頻轉文字的工作吧。於是花了一些時間做了一個Demo,對於一些比較好的視頻,比如演講視頻,效果還是不錯的。

我用 TED的演講做了一個Demo,TED演講者英語清晰,噪音也少:

Ted視頻來自:AomawaShields_2015U.mp4

自動生成的字幕文件見:ted80001.srt

在我的python腳本中,基本的思路是:

(1)將長語音文件切割成小的語音文件。

(2)直接用Baidu的語音識別,做小文件的語音到文字的識別

(3)小語音文件包括了語音的開始時間和結束時間,所以能做字幕

其實裡面比較不容易處理的就是將長文件切割成小的語音文件,經過一些思考有了下面的一個切割過程:

(1)提取wav文件的數據,對數據做一些平滑處理

(2)將數據做歸一化處理

(3)設定一個閾值,用來定義用戶的停頓閾值(歸一化以後我取 0.2)。對於語音的每一個數值超過這個閾值算說話,低於這個算停頓。統計連續的停頓和連續的說話點的長度。

(4)對於所有的統計的長度數據,按照停頓的時間長短排序

(5)按照排序的數據做切割,越靠前面的越是應該被切割。切割什麼時候停止?切割以後的所有小音頻小於某個指定的指定試講長度就停止。基本上根據我的經驗可以設定這個值為17S左右。

(6)有了這些小音頻,就可以用已有的語音識別技術做語音到文字的識別了,甚至添加字幕。

以後也可以加些自動翻譯的東西進去。

如果是碼農請參見,我的項目:github。

如果想聽一下切割效果,點擊下面鏈接看百度網盤。切割文件按照 ID_起始時間_結束時間命名的( ID 從1開始)

以後學英語或者學音樂可以先把長音頻切割成小的一句一句的學,方便多了。

TED音頻文件分割以後的小音頻 清唱

清唱我只在乎你切割後小音頻 TED

中文識別 小蝌蚪找媽媽:

睡前故事,

小蝌蚪找媽媽,

小蝌蚪在池塘里游啊游,

遇到媽媽帶著一群小鴨也在池塘里有水,小鴨跟著鴨媽媽身邊,不停的叫著媽媽,

下課都想我們的媽媽在哪裡呢,

他們有到呀媽媽身邊問道,鴨媽媽,您知道我們的媽媽長什麼樣嗎?

你們的媽媽,頭上有兩隻大眼睛,

嘴巴又大又寬,

小蝌蚪覺得,大禹像媽媽就趕緊追上去喊媽媽媽媽,大魚笑著說我不是你們的媽媽,

你們的媽媽有四條腿,

小蝌蚪看見烏龜有四條腿,

就追上去喊,

媽媽媽媽,烏龜笑著說,我不是你們的媽媽,你們的媽媽肚皮是白色的,

小蝌蚪看見看到一隻大白鵝高興,要上去咯,

媽媽,大白鵝說你們的媽媽穿著綠衣服,

會呱呱的唱歌,小蝌蚪看見一隻青蛙坐在,荷葉上,身上穿著綠衣服,

青蛙呱呱的說,我的孩子們快過來我就是你們的媽媽,那為什麼我和您長的不一樣呢,

等你們長大就和媽媽一樣了,

小蝌蚪終於找到媽媽了,他們高興地在水裡游來游去,

後來小蝌蚪慢慢的長出了四條腿,尾巴也不見了,還換上了綠衣裳,變成了真正的青蛙,

他們每天都在岸邊走害蟲,

是人類的好朋友哦,

英文識別結果:

our,

the,the,

i am in search of another planet in the universe where life exists,

icantsee this planet with my naked eyes,or even with the most powerful telescopes we currently possess,

but i know thatitsthere,

and understanding contradictions that occur in nature will help find,

on our planet where there is water there is life,

so we look for planets that orbit at just the right distance from their stars,

at this distance shown in blue on this diagram for stars of different temperatures planets could be warm enough for water to flow on their surfaces has lakes and oceans where life might reside,

some astronomers focus their time and energy on finding planets that these distances from their stars on,

what i do takes up where their job and,

i model the possible climates affect the planet,

andhereswhythatsimportant there are many factors besides distance from its star that control whether a planet can support life,

take the planet venus,

ITsnamed after the roman goddess of love and beauty because of its benign if serial appearance in the sky,

but spacecraft measurements revealed a different story,

the surface temperature is close to nine hundred degrees fahrenheit five hundred celsius,

thatshot enough to melt lead,

its thick atmosphere not its distance from the sun is the reason causes the greenhouse effect on steroids trapping heat from the sun is scorching the planet surface,

the reality totally contradicted initial perceptions on this planet,

from these lessons from our own solar systemwevelearned that aplanetsatmosphere is crucial to its climate and potential to host life,

wedontknow what the atmospheres of these planets are like because the planets are so small in game compared to their stars,and so far away from us,

for example one of the closest planet that could support surface water is called least six six seven cc touch a glamorous name write, my phone number for a nameitstwenty three light years away,

sothatsmore than one hundred trillion miles,

trying to measure the atmospheric composition of axle planet passing in front of its host star for his hard,

ITslike trying to see a fruit fly passing by acarsheadlight,

they now imagine that cause one hundred trillion miles away and you want to know the precise color of the fly,

so i use computer models to calculate the kind of atmosphere a planet would need you have suitable climate for water and life,

heresanartistsconcept of the planet kepler sixty to ask with your for reference,

ITstwelve hundred light years away and just forty percent larger than earth,

or in excess funded work found that IT could be warm enough for open water for many types of atmospheres and orientations of its orbit to live like feature telescope to follow up on this planet to look for signs of life,

ice on a planet surface is also important for climate ice absorbs longer redder wavelengths of light and reflects shorter bluer light,

thatswhy the iceberg in the photo looks so blue the redder light from the sun is absorbed on its way through the ice only the blue light makes IT all the way to the bottom,

the gets reflected back up to our eyes as we see blue wife,

my model show that planets orbiting cooler stars could actually be warmer than planets orbiting hotter stars she does another contradiction that ice absorbs the longer wavelength light from cooler stars in that light that energy,

heats the ice,

using climate models,to explore how these contradictions can affect planetary climate is vital to the search for life elsewhere,

anditsno surprise that this,

my specialty,

imafrican american female astronomer,and a classically trained actor who love to wear make up and read fashion magazines so i am uniquely positioned to appreciate contradictions in nature,

the,and how they can inform our search for the next planet where life exists,

my organization rising star girls teaches astronomy to middle school girls of color,

using theatre writing and visual arts,

thatsanother contradiction science and artdontoften go together but interweaving them can help these girls bring their whole selves to what a large and maybe one day,

join the ranks of astronomers were full of contradictions can use a background to discover once and for all that we are truly not alone in the universe,

thank you,the,


推薦閱讀:

人工智慧入門:AI產品經理需要了解的五大語音交互評價指標
無線智能音響的新潮流
語音交互文章集錦(長期更新)
【今日直播】語音技術的前世今生:深度學習與GMM+HMM
語音基礎知識

TAG:字幕 | 語音識別 | 自動化 |