diff --git a/demos/audio_tagging/README.md b/demos/audio_tagging/README.md index 86971a313e61b1d66a72affe331a25491135a514..88ff363750e0453e3766a9d6b465d26075e2c785 100644 --- a/demos/audio_tagging/README.md +++ b/demos/audio_tagging/README.md @@ -1,3 +1,5 @@ +([简体中文](./README_cn.md)|English) + # Audio Tagging ## Introduction diff --git a/demos/audio_tagging/README_cn.md b/demos/audio_tagging/README_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..3331a83a69625f178c685fbe18b565c2e70e3a03 --- /dev/null +++ b/demos/audio_tagging/README_cn.md @@ -0,0 +1,95 @@ + +(简体中文|[English](./README.md)) + +# 声音分类 +## 介绍 +声音分类任务为音频片段添加一个或多个标签的任务,包括音乐分类、声学场景分类、音频事件分类等。 + +这个 demo 使用 527 个 [AudioSet](https://research.google.com/audioset/) 数据集中的标签为音频进行分类,它可以通过使用 `PaddleSpeech` 的单个命令或 python 中的几行代码来实现。 + +## 使用方法 +### 1. 安装 +```bash +pip install paddlespeech +``` +### 2. 准备输入 +这个 demo 的输入应该是一个 WAV 文件(`.wav`), + +可以下载此 demo 的示例音频: +```bash +wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/cat.wav https://paddlespeech.bj.bcebos.com/PaddleAudio/dog.wav +``` + +### 3. 使用方法 +- 命令行 (推荐使用) + ```bash + paddlespeech cls --input ./cat.wav --topk 10 + ``` + 使用方法: + ```bash + paddlespeech cls --help + ``` + 参数: + - `input`(必须输入): 用于分类的音频。 + - `model`: 声音分类任务的模型, 默认值: `panns_cnn14`. + - `config`: 声音分类任务的配置文件,若不设置则使用预训练模型中的默认配置, 默认值: `None`。 + - `ckpt_path`:模型参数文件, 若不设置则下载预训练模型使用, 默认值: `None`。 + - `label_file`:声音分类任务的标签文件,若不是设置则使用音频数据集标签,默认值: `None`。 + - `topk`:展示分类结果的 topk 个结果,默认值: `1`。 + - `device`:执行预测的设备,默认值:当前系统下 paddlepaddle 的默认 device。 + + 输出: + ```bash + [2021-12-08 14:49:40,671] [ INFO] [utils.py] [L225] - CLS Result: + Cat: 0.8991316556930542 + Domestic animals, pets: 0.8806838393211365 + Meow: 0.8784668445587158 + Animal: 0.8776564598083496 + Caterwaul: 0.2232048511505127 + Speech: 0.03101264126598835 + Music: 0.02870696596801281 + Inside, small room: 0.016673989593982697 + Purr: 0.008387474343180656 + Bird: 0.006304860580712557 + ``` + +- Python API + ```python + import paddle + from paddlespeech.cli import CLSExecutor + + cls_executor = CLSExecutor() + result = cls_executor( + model='panns_cnn14', + config=None, # Set `config` and `ckpt_path` to None to use pretrained model. + label_file=None, + ckpt_path=None, + audio_file='./cat.wav', + topk=10, + device=paddle.get_device()) + print('CLS Result: \n{}'.format(result)) + ``` + 输出: + ```bash + CLS Result: + Cat: 0.8991316556930542 + Domestic animals, pets: 0.8806838393211365 + Meow: 0.8784668445587158 + Animal: 0.8776564598083496 + Caterwaul: 0.2232048511505127 + Speech: 0.03101264126598835 + Music: 0.02870696596801281 + Inside, small room: 0.016673989593982697 + Purr: 0.008387474343180656 + Bird: 0.006304860580712557 + ``` + +### 4. 预训练模型 + +以下是 PaddleSpeech 提供的可以被命令行和 python api 使用的预训练模型列表: + +| 模型 | 采样率 +| :--- | :---: +| panns_cnn6| 32000 +| panns_cnn10| 32000 +| panns_cnn14| 32000 diff --git a/demos/automatic_video_subtitiles/README.md b/demos/automatic_video_subtitiles/README.md index 43bf6f56e13e5a38741aefff7652d7c30363a98a..df4b0e264b1f1a5c64d896efe06bb44dc631630e 100644 --- a/demos/automatic_video_subtitiles/README.md +++ b/demos/automatic_video_subtitiles/README.md @@ -1,3 +1,4 @@ +([简体中文](./README_cn.md)|English) # Automatic Video Subtitiles ## Introduction diff --git a/demos/automatic_video_subtitiles/README_cn.md b/demos/automatic_video_subtitiles/README_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..b217f921d7d5203a09308c050a3b076bf977a8a6 --- /dev/null +++ b/demos/automatic_video_subtitiles/README_cn.md @@ -0,0 +1,44 @@ +(简体中文|[English](./README.md)) +# 视频字幕生成 +## 介绍 +视频字幕生成可以使用语音识别系统从特定视频生成字幕。 + +这个 demo 是一个为视频自动生成字幕的实现,它可以通过使用 `PaddleSpeech` 的单个命令或 python 中的几行代码来实现。 +## 使用方法 +### 1. 安装 +```bash +pip install paddlespeech +``` +### 2. 准备输入 +获取包含特定语言语音的视频文件: +```bash +wget -c https://paddlespeech.bj.bcebos.com/demos/asr_demos/subtitle_demo1.mp4 +``` +从视频文件中提取单通道的 16kHz 采样率的 `.wav` 文件: +```bash +ffmpeg -i subtitle_demo1.mp4 -ac 1 -ar 16000 -vn input.wav +``` +### 3. 使用方法 +- Python API + ```python + import paddle + from paddlespeech.cli import ASRExecutor, TextExecutor + + asr_executor = ASRExecutor() + text_executor = TextExecutor() + + text = asr_executor( + audio_file='input.wav', + device=paddle.get_device()) + result = text_executor( + text=text, + task='punc', + model='ernie_linear_p3_wudao', + device=paddle.get_device()) + print('Text Result: \n{}'.format(result)) + ``` + 输出: + ```bash + Text Result: + 当我说我可以把三十年的经验变成一个准确的算法,他们说不可能。当我说我们十个人就能实现对十九个城市变电站七乘二十四小时的实时监管,他们说不可能。 + ``` diff --git a/demos/punctuation_restoration/README.md b/demos/punctuation_restoration/README.md index 50b50473996c247682bb70ec2633f6a4596b44dc..966e387c6431bdb8b8da63c48ea693817111f2f6 100644 --- a/demos/punctuation_restoration/README.md +++ b/demos/punctuation_restoration/README.md @@ -1,3 +1,4 @@ +([简体中文](./README_cn.md)|English) # Punctuation Restoration ## Introduction Punctuation restoration is a common post-processing problem for Automatic Speech Recognition (ASR) systems. It is important to improve the readability of the transcribed text for the human reader and facilitate NLP tasks. diff --git a/demos/punctuation_restoration/README_cn.md b/demos/punctuation_restoration/README_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..4f1e012391cfb899cecd375d33a12a6e80923985 --- /dev/null +++ b/demos/punctuation_restoration/README_cn.md @@ -0,0 +1,73 @@ +(简体中文|[English](./README.md)) + +# 标点恢复 +## 介绍 + +标点恢复是语音识别系统中常见的后处理步骤。提高转录文本的可读性对于人类阅读和后续的自然语言处理任务是非常重要的。 + +这个 demo 是一个为原始文本恢复标点的实现,它可以通过使用 `PaddleSpeech` 的单个命令或 python 中的几行代码来实现。 + +## 使用方法 +### 1. 安装 +```bash +pip install paddlespeech +``` +### 2. 准备输入 +这个 demo 的输入是通过参数传递的特定语言的文本。 + +### 3. 使用方法 +- 命令行 (推荐使用) + ```bash + paddlespeech text --input 今天的天气真不错啊你下午有空吗我想约你一起去吃饭 + ``` + 使用方法: + ```bash + paddlespeech text --help + ``` + 参数: + - `input`(必须输入):原始文本。 + - `task`:子任务,默认值:`punc`。 + - `model`:文本模型类型,默认值:`ernie_linear_p7_wudao`。 + - `lang`:模型语言, 默认值:`zh`。 + - `config`:文本任务的配置文件,若不设置则使用预训练模型中的默认配置,默认值:`None`。 + - `ckpt_path`:模型参数文件, 若不设置则下载预训练模型使用,默认值:`None`。 + - `punc_vocab`:标点恢复任务的标点词表文件,默认值:`None`。 + - `device`:执行预测的设备,默认值:当前系统下 paddlepaddle 的默认 device。 + + 输出: + ```bash + [2021-12-14 19:50:22,200] [ INFO] [log.py] [L57] - Text Result: + 今天的天气真不错啊!你下午有空吗?我想约你一起去吃饭。 + ``` + +- Python API + ```python + import paddle + from paddlespeech.cli import TextExecutor + + text_executor = TextExecutor() + result = text_executor( + text='今天的天气真不错啊你下午有空吗我想约你一起去吃饭', + task='punc', + model='ernie_linear_p7_wudao', + lang='zh', + config=None, + ckpt_path=None, + punc_vocab=None, + device=paddle.get_device()) + print('Text Result: \n{}'.format(result)) + ``` + 输出: + ```bash + Text Result: + 今天的天气真不错啊!你下午有空吗?我想约你一起去吃饭。 + ``` + +### 预训练模型 +以下是 PaddleSpeech 提供的可以被命令行和 python API 使用的预训练模型列表: + +- 标点恢复 + | 模型 | 语言 | 标点类型数 + | :--- | :---: | :---: + | ernie_linear_p3_wudao| zh | 3(,。?) + | ernie_linear_p7_wudao| zh | 7(,。!?、:;) diff --git a/demos/speech_recognition/README.md b/demos/speech_recognition/README.md index 5d21564fe4705f842a6c8c25bfdc00505df3b49e..1059a0c105359ac42f168afde75c2f9f5340f732 100644 --- a/demos/speech_recognition/README.md +++ b/demos/speech_recognition/README.md @@ -1,3 +1,4 @@ +([简体中文](./README_cn.md)|English) # ASR(Automatic Speech Recognition) ## Introduction diff --git a/demos/speech_recognition/README_cn.md b/demos/speech_recognition/README_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..29e2343d38b80f177f8828c476b203a5df5be909 --- /dev/null +++ b/demos/speech_recognition/README_cn.md @@ -0,0 +1,72 @@ +(简体中文|[English](./README.md)) + +# 语音识别 +## 介绍 +语音识别解决让计算机程序自动转录语音的问题。 + +这个 demo 是一个从给定音频文件识别文本的实现,它可以通过使用 `PaddleSpeech` 的单个命令或 python 中的几行代码来实现。 +## 使用方法 +### 1. 安装 +```bash +pip install paddlespeech +``` +### 2. 准备输入 +这个 demo 的输入应该是一个 WAV 文件(`.wav`),并且采样率必须与模型的采样率相同。 + +可以下载此 demo 的示例音频: +```bash +wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespeech.bj.bcebos.com/PaddleAudio/en.wav +``` +### 3. 使用方法 +- 命令行 (推荐使用) + ```bash + paddlespeech asr --input ./zh.wav + ``` + 使用方法: + ```bash + paddlespeech asr --help + ``` + 参数: + - `input`(必须输入):用于识别的音频文件。 + - `model`:ASR 任务的模型,默认值:`conformer_wenetspeech`。 + - `lang`:模型语言,默认值:`zh`。 + - `sample_rate`:音频采样率,默认值:`16000`。 + - `config`:ASR 任务的参数文件,若不设置则使用预训练模型中的默认配置,默认值:`None`。 + - `ckpt_path`:模型参数文件,若不设置则下载预训练模型使用,默认值:`None`。 + - `device`:执行预测的设备,默认值:当前系统下 paddlepaddle 的默认 device。 + + 输出: + ```bash + [2021-12-08 13:12:34,063] [ INFO] [utils.py] [L225] - ASR Result: 我认为跑步最重要的就是给我带来了身体健康 + ``` + +- Python API + ```python + import paddle + from paddlespeech.cli import ASRExecutor + + asr_executor = ASRExecutor() + text = asr_executor( + model='conformer_wenetspeech', + lang='zh', + sample_rate=16000, + config=None, # Set `config` and `ckpt_path` to None to use pretrained model. + ckpt_path=None, + audio_file='./zh.wav', + device=paddle.get_device()) + print('ASR Result: \n{}'.format(text)) + ``` + + 输出: + ```bash + ASR Result: + 我认为跑步最重要的就是给我带来了身体健康 + ``` + +### 4.预训练模型 +以下是 PaddleSpeech 提供的可以被命令行和 python API 使用的预训练模型列表: + +| 模型 | 语言 | 采样率 +| :--- | :---: | :---: | +| conformer_wenetspeech| zh| 16000 +| transformer_aishell| zh| 16000 diff --git a/demos/speech_translation/README.md b/demos/speech_translation/README.md index afc9ac5387c205d92824f612fbfb4f84bbffe14c..a2041b0c9bff13f36327dc3abb3e1f780d970416 100644 --- a/demos/speech_translation/README.md +++ b/demos/speech_translation/README.md @@ -1,4 +1,3 @@ - ([简体中文](./README_cn.md)|English) # Speech Translation ## Introduction diff --git a/demos/speech_translation/README_cn.md b/demos/speech_translation/README_cn.md index ee192e167d000e7965a91c491ff7b7207a570866..affa82282798e6107998140c172b5f240cf8ffa2 100644 --- a/demos/speech_translation/README_cn.md +++ b/demos/speech_translation/README_cn.md @@ -11,7 +11,6 @@ ```bash pip install paddlespeech ``` - ### 2. 准备输入 这个 Demo 的输入是 WAV(`.wav`) 语音文件 @@ -25,21 +24,21 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee ```bash paddlespeech st --input ./en.wav ``` - 使用方法: + 使用方法: ```bash paddlespeech st --help ``` - 参数: - - `input`(required): 用于翻译的音频. - - `model`: 语音翻译的模型类型. 默认: `fat_st_ted`. - - `src_lang`: 源语言. 默认: `en`. - - `tgt_lang`: 目标语言. 默认: `zh`. - - `sample_rate`: 输入音频的采样率. 默认: `16000`. - - `config`: 语音翻译任务的配置文件. 如果没有默认使用预训练模型的配置文件. 默认: `None`. - - `ckpt_path`: 模型文件. 如果没有默认使用预训练模型. 默认: `None`. - - `device`: 选择执行的设备. 默认: 当前环境 paddlepaddle 的默认设备. + 参数: + - `input`(必须输入):用于翻译的音频。 + - `model`: 语音翻译的模型类型. 默认:`fat_st_ted`。 + - `src_lang`: 源语言. 默认:`en`。 + - `tgt_lang`: 目标语言. 默认:`zh`。 + - `sample_rate`:输入音频的采样率. 默认:`16000`。 + - `config`:语音翻译任务的配置文件. 如果没有默认使用预训练模型的配置文件. 默认:`None`。 + - `ckpt_path`:模型文件. 如果没有默认使用预训练模型. 默认:`None`。 + - `device`:选择执行的设备. 默认: 当前环境 paddlepaddle 的默认设备。 - 输出: + 输出: ```bash [2021-12-09 11:13:03,178] [ INFO] [utils.py] [L225] - ST Result: ['我 在 这栋 建筑 的 古老 门上 敲门 。'] ``` @@ -62,16 +61,15 @@ wget -c https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav https://paddlespee print('ST Result: \n{}'.format(text)) ``` - 输出: + 输出: ```bash ST Result: ['我 在 这栋 建筑 的 古老 门上 敲门 。'] ``` - ### 4. 预训练模型 -以下是 PaddleSpeech 提供的可以被命令行和 python api 使用的预训练模型列表: +以下是 PaddleSpeech 提供的可以被命令行和 python API 使用的预训练模型列表: | 模型 | 源语言 | 目标语言 | :--- | :---: | :---: | diff --git a/demos/text_to_speech/README_cn.md b/demos/text_to_speech/README_cn.md index a7f4c386034c79548493b433946f4ac0d2f2dd76..0b2cd0b5dad69a8bdb7cea6f42666dfa05a837c4 100644 --- a/demos/text_to_speech/README_cn.md +++ b/demos/text_to_speech/README_cn.md @@ -44,30 +44,30 @@ pip install paddlespeech ```bash paddlespeech tts --am fastspeech2_vctk --voc pwgan_vctk --input "hello, boys" --lang en --spk_id 0 ``` - 使用方法: + 使用方法: ```bash paddlespeech tts --help ``` - 参数: + 参数: - `input`(必须输入):用于合成音频的文本。 - - `am`:TTS 任务的声学模型, 默认值: `fastspeech2_csmsc`。 - - `am_config`:声学模型的配置文件,若不设置则使用默认配置,默认值: `None`。 - - `am_ckpt`:声学模型的参数文件,若不设置则下载预训练模型使用,默认值: `None`。 - - `am_stat`:训练声学模型时用于正则化 mel 频谱图的均值标准差文件,默认值: `None`。 - - `phones_dict`:音素词表文件, 默认值: `None`。 - - `tones_dict`:声调词表文件, 默认值: `None`。 - - `speaker_dict`:说话人词表文件, 默认值: `None`。 + - `am`:TTS 任务的声学模型, 默认值:`fastspeech2_csmsc`。 + - `am_config`:声学模型的配置文件,若不设置则使用默认配置,默认值:`None`。 + - `am_ckpt`:声学模型的参数文件,若不设置则下载预训练模型使用,默认值:`None`。 + - `am_stat`:训练声学模型时用于正则化 mel 频谱图的均值标准差文件,默认值:`None`。 + - `phones_dict`:音素词表文件, 默认值:`None`。 + - `tones_dict`:声调词表文件, 默认值:`None`。 + - `speaker_dict`:说话人词表文件, 默认值:`None`。 - `spk_id`:说话人 id, 默认值: `0`。 - `voc`:TTS 任务的声码器, 默认值: `pwgan_csmsc`。 - - `voc_config`:声码器的配置文件,若不设置则使用默认配置,默认值: `None`。 - - `voc_ckpt`:声码器的参数文件,若不设置则下载预训练模型使用,默认值: `None`。 - - `voc_stat`:训练声码器时用于正则化 mel 频谱图的均值标准差文件,默认值: `None`。 - - `lang`:TTS 任务的语言, 默认值: `zh`。 + - `voc_config`:声码器的配置文件,若不设置则使用默认配置,默认值:`None`。 + - `voc_ckpt`:声码器的参数文件,若不设置则下载预训练模型使用,默认值:`None`。 + - `voc_stat`:训练声码器时用于正则化 mel 频谱图的均值标准差文件,默认值:`None`。 + - `lang`:TTS 任务的语言, 默认值:`zh`。 - `device`:执行预测的设备, 默认值:当前系统下 paddlepaddle 的默认 device。 - `output`:输出音频的路径, 默认值:`output.wav`。 - 输出: + 输出: ```bash [2021-12-09 20:49:58,955] [ INFO] [log.py] [L57] - Wave file has been generated: output.wav ``` @@ -98,13 +98,13 @@ pip install paddlespeech print('Wave file has been generated: {}'.format(wav_file)) ``` - 输出: + 输出: ```bash Wave file has been generated: output.wav ``` ### 4. 预训练模型 -以下是 PaddleSpeech 提供的可以被命令行和 python api 使用的预训练模型列表: +以下是 PaddleSpeech 提供的可以被命令行和 python API 使用的预训练模型列表: - 声学模型 | 模型 | 语言