File size: 2,116 Bytes
3bb42a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/local/bin/python3
#-*- coding:utf-8 -*-
import gradio as gr

title = "OpenAI Whisper Large v2"

description = """
本例用于演示 <b>openai/whisper-large-v2</b> 模型的语音识别(ASR)能力。目前没有对模型做微调,基于原始模型开发。 Whisper原始模型主要支持英语语音的识别。英语的效果最好,中文语音识别后只会输出汉语拼音。

<b>更多的信息请参考:</b> <a href="https://huggingface.co/openai/whisper-large-v2">openai/whisper-large-v2</a>。

<b>使用方法:</b> 上传一个音频文件或直接在页面中录制音频。音频会在传递到模型之前转换为单声道并重新采样为16 kHz。
"""

article = """
<div style='margin:20px auto;'>

<p>
    参考:  
    <a href="https://huggingface.co/openai/whisper-large-v2">OpenAI Whisper Large v2</a> |
    <a href="https://github.com/innev">Innev GitHub</a> 
</p>

<p>音频案例:<p>
<ul>
<li>"春日阳光普照大地,正是踏春好时节" 来源: 知琪(Zhiqi)
<li>"Hmm, I don't know" 来源: <a href="https://freesound.org/people/InspectorJ/sounds/519189/">InspectorJ</a> (CC BY 4.0 license)
<li>"Henry V" excerpt 来源: <a href="https://freesound.org/people/acclivity/sounds/24096/">acclivity</a> (CC BY-NC 4.0 license)
<li>"You can see it in the eyes" 来源: <a href="https://freesound.org/people/JoyOhJoy/sounds/165348/">JoyOhJoy</a> (CC0 license)
<li>"We yearn for time" 来源: <a href="https://freesound.org/people/Sample_Me/sounds/610529/">Sample_Me</a> (CC0 license)
</ul>
</div>
"""

examples = [
    ["examples/zhiqi.wav", None],
    ["examples/hmm_i_dont_know.wav", None],
    ["examples/henry5.mp3", None],
    ["examples/yearn_for_time.mp3", None],
    ["examples/see_in_eyes.wav", None],
]

gr.load(
    "models/openai/whisper-large-v2",
    inputs=[
        gr.Audio(label="上传语音", source="upload", type="numpy"),
        gr.Audio(label="录制语音", source="microphone", type="numpy"),
    ],
    outputs=gr.Text(label="识别出的文字"),
    title=title,
    description=description,
    article=article,
    examples=examples
).launch()