tihu-nlp / tihu

Persian Text-To-Speech
http://lilak-project.com/tihu_demo.php
Other
84 stars 11 forks source link

docker grpc crash segmentation fault after query #41

Closed shotor closed 4 years ago

shotor commented 4 years ago

Hi @b00f, love the work you put into this

I'm building a small os react-native client and trying to run tihu as a grpc service through docker.

It builds fine and starts up, but when doing a query it crashes with:

Segmentation fault (core dumped)

My code: https://github.com/shotor/tihu-grpc-js/blob/master/index.js

Am I doing something wrong?

b00f commented 4 years ago

Hi @shotor. I always though my github-id is weird, your is funnier! Your project sounds great. I will check it and update you here soon.

Thanks for using Tihu.

b00f commented 4 years ago

Hi again. I checked your code. The problem is passing invalid voice to Tihu. Currently tihu supporting following voices:

TIHU_VOICE_MBROLA_MALE    = 0
TIHU_VOICE_MBROLA_FEMALE  = 1
TIHU_VOICE_ESPEAK_MALE    = 2
TIHU_VOICE_ESPEAK_FEMALE  = 3

To fix the issue you can change the voice id to zero(0)

The best solution is defining an enum for voice in protobuf. please go ahead if you have time to update the tihu.prto. Here is a reference might help: https://developers.google.com/protocol-buffers/docs/proto3#enum

b00f commented 4 years ago

It is bad of me that I didn't check if the voice is out of the range! sorry

shotor commented 4 years ago

No worries, it works now! Thanks for checking the issue. I made a PR to type the voice parameter

I had to guess at the audio options, frequence, sample rate etc. because I couldn't find them in the repo. These are the options that worked for me:

sampleRate: 22050,
channels: 1,
bitDepth: 16,

Are these correct? And are they the same for all the voices? Maybe it's good to add these to the readme

Also, I don't think the API should completely crash because of a bad input value. Should return an error to the user. I've never worked with C++ but I'll see if I can fix that

b00f commented 4 years ago

Yup. Those option are correct. Let me explain more: Sample rate is fixed in Tihu and it is always 22050 Hz. Tihu is using src for resampling audio data. look here.

However the method name is not so nice. Maybe ParseSample make more sence here thatn PlaySample

About volume and pitches, the tihu itself has the apis to adjust them: here Maybe we need to add these params to the proto file.