Coder Social home page Coder Social logo

amintakhtinejad / persian-tts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amadeomano/persian-tts

0.0 1.0 0.0 19.58 MB

๐Ÿ”Š A simple human-based text-to-speach synthesiser and ReactNative app for Persian language.

License: GNU General Public License v3.0

JavaScript 75.25% Python 5.15% Java 5.69% Ruby 3.62% Objective-C 10.30%

persian-tts's Introduction

Persian Text-to-Speach synthesizer

PersianTTS is GPLv3 licensed.

Persian TTS is a simple text-to-speach synthesizing engine and ReactNative app that I have initially developed as my Bachelor's degree graduation project.

The project is however meant to get gradual improvements over time.

Contents

โœ… Requirements

Persian-TTS apps are powered by React Native so you will need it for compiling the apps properly. To compile android version, having a proper Android SDK on your machine is a must and evidently compiling iOS varient needs you to have a working Xcode copy and a functional Cocoapods dependency management tool on a MacOS operating system powered machine.

You will also need to have a dependency management tool for accessing NPM and download project's dependencies. Yarn is used in this project but NPM or other tools could also be used.

๐Ÿ—บ Installation guide

First you can get the source code by cloning it

git clone [email protected]:amfolio/persian-tts.git

iOS dependencies installation (Optional)

cd ios
pod install

Then move to the package's directory and install it's dependencies using yarn install or npm install

๐Ÿš€ Launching apps

To launch apps in emulators of Android and/or iOS operating systems, you can use following commands:

Android

react-native run-android

iOS

react-native run-ios

๐Ÿ— Project structure

This project's structure is just identical to many other ReactNative project structures. below is just a big picture of the main structure:

  • __tests__ : Jest powered unit tests
  • android : ReactNative android source files
  • ios : ReactNative ios source files
  • src : Main project root
    • components : Reusable React components
      • ComponentName : A CamelCase named folder wrapping over component files
        • index.js : The component entry point, exporting it's contents using ES6 modules
        • styles.js (optional): component's ReactNative style-sheets
    • screen : Application screen components
    • utils : Synthesizer algorithms & other language processing tools
    • App.js : Main application entry
    • Router.js : React-Navigation component configurations
    • voices.json : Application wide available voices configs

๐Ÿ›  How it works

Shortly the project uses a "concatnative synthesizing" apprach to achieve it's goal. In persian language, an unlimited set of words could be constructed by concatnating "consonant+vowel" pairs. For bravity here we call these pairs simply "Syllables".

To make the synthesizing work, the project has initially a set of 169 syllable voices, recoded from my own voice (so it's not a professional narration ๐Ÿ˜…). this number is devided as bellow:

Voice type Corresponding files count
vowels 6
silent consonants 23
syllable (consonant+vowel) 138
spaces 2
Total 169

The synthesizing process is then feasable by concatnating syllables using FFmpeg library and it's react-native-ffmpeg wrapper. Here is a quick schema of what happens.

1๏ธโƒฃ Step 1

In the first step, the phonetic corresponding for of persian input is created using TextToPhonems utility function.

const input = "ุณู„ุงู…"; // means "Hello" in persian
const output = textToPhonems(input); // ["sa", "lฤ", "m"];

2๏ธโƒฃ Step 2

The result of step 1 passes through PhonemsToFFMpeg utility function and gets a valid ffmpeg concatnation command:

const ffmpeg = phonemsToFFMpeg(output);

and the result would be:

ffmpeg \
  -I sa.wav -I lฤ.wav -I m.wav \
  -filter_complex โ€˜[0:0][1:0][2:0]concat=n=3:v=0:a=1[out]โ€™ \
  -map โ€˜[out]โ€™ output.wav

3๏ธโƒฃ Step 3

The application calls ffmpeg using react-native-ffmpeg and the following steps get done behind the scenes:

Before concatnation
sa.wav lฤ.wav m.wav
After concatnation
output.wav

4๏ธโƒฃ Step 4

The output audio file gets played over both iOS and Android platforms thanks to react-native-sound library. Reading bundle resources and transfering them to sandbox/SD-card location is also possible thanks to react-native-fs

๐Ÿ™๐Ÿป Acknowledgments

The special thank you goes to my project's director, Dr. Mohammad Taheri who gave me the confidence of approaching this subject and guided me through the best steps to make it possible. Without him I would have probably never get into such academic researches.

The next big thanks goes to the developers community who generousely share the cutting edge technology with others. It's just thanks to this community that reinventing the wheels is not anymore necessary.

Here is a short list of libraries who helped me infinitely in my development path:

๐Ÿค Contribution

This repository is initially constructed as a minimum effort for a Persian language open-source Text-To-Speech solution. I would be highly grateful of any contribution from issues reporting to bugfixes and improvements.

Contribution by adding more voices to the project is also highly welcomed and you can also mention your name in voices.json.

Please feel free to send pull requests in case of feeling any necessity.

persian-tts's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.