/parrots

Automatic Speech Recognition(ASR), Text-To-Speech(TTS) engine for Chinese. 中文语音识别、文字转语音,基于语音库实现,易扩展。

Primary LanguagePythonApache License 2.0Apache-2.0

alt text

PyPI version Downloads Contributions welcome GitHub contributors License Apache 2.0 python_vesion GitHub issues Wechat Group

Parrots

Parrots, Automatic Speech Recognition(ASR), Text-To-Speech(TTS) engine.

parrots实现了中文语音识别和语音合成模型,开箱即用。

Guide

Feature

  1. ASR:基于 Tensorflow2 实现的中文语音识别(ASR)模型
  2. TTS:基于中文语音库的语音合成(TTS)模型

Install

brew install portaudio
pip install -r requirements.txt
  • pip install parrots
  • Or
git clone https://github.com/shibing624/parrots.git
cd parrots
python3 setup.py install

Demo

Official Demo: https://www.mulanai.com/product/asr/

Usage

ASR

example: examples/demo_asr.py

import os
import sys

sys.path.append('..')
from parrots import SpeechRecognition, Pinyin2Hanzi

pwd_path = os.path.abspath(os.path.dirname(__file__))

if __name__ == '__main__':
    m = SpeechRecognition()
    r = m.recognize_speech_from_file(os.path.join(pwd_path, 'tushuguan.wav'))
    print('[提示] 语音识别结果:', r)

    n = Pinyin2Hanzi()
    text = n.pinyin_2_hanzi(r)
    print('[提示] 语音转文字结果:', text)

output:

北京图书馆

TTS(Speech Synthesis)

example: examples/demo_tts.py

import sys

sys.path.append('..')
from parrots import TextToSpeech

if __name__ == '__main__':
    m = TextToSpeech()
    # say text
    m.speak('北京图书馆')

    # generate wav file to path
    m.synthesize('北京图书馆', output_wav_path='./out.wav')

output:

北京图书馆

Dataset

语音库

从SourceForge下载语音库syllables.zip,并解压到parrots/data目录下

wget https://sourceforge.net/projects/hantts/files/syllables.zip --no-check-certificate

录制新的语音库

  • 按阴平、阳平、上声、去声、轻声的顺序录下 mapping.json 里每一个音节的五个声调
  • 按开头字母(letter)分组, 将文件存在 ./recording/{letter}.wav下
  • 运行 python parrots.custom_syllables.py {letter} 将{letter}.wav 完整的录音分成独立的拼音
  • 检查核对./pre文件夹中的拼音.wav后导入文件夹./syllables

Contact

  • Issue(建议):GitHub issues
  • 邮件我:xuming: xuming624@qq.com
  • 微信我:加我微信号:xuming624, 进Python-NLP交流群,备注:姓名-公司名-NLP

Citation

如果你在研究中使用了parrots,请按如下格式引用:

@misc{parrots,
  title={parrots: ASR and TTS Tool},
  author={Xu Ming},
  year={2022},
  howpublished={\url{https://github.com/shibing624/parrots}},
}

License

授权协议为 The Apache License 2.0,可免费用做商业用途。请在产品说明中附加parrots的链接和授权协议。

Contribute

项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:

  • tests添加相应的单元测试
  • 使用python -m pytest来运行所有单元测试,确保所有单测都是通过的

之后即可提交PR。

Reference

ASR

TTS(Speech Synthesis)