Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中获得等效的Google文本到语音基音_Android_Google Cloud Platform_Google Text To Speech - Fatal编程技术网

如何在Android中获得等效的Google文本到语音基音

如何在Android中获得等效的Google文本到语音基音,android,google-cloud-platform,google-text-to-speech,Android,Google Cloud Platform,Google Text To Speech,我通过设置音调和语速“创建”了一个定制的谷歌TTS语音 我为pitch选择的值为负(-6.4),我想在我的Android应用程序中使用精确的值 但是,TextToSpeech.setPitch(float)不能接受负值。以下是android.speech.tts.TextToSeech中的代码: public int setPitch(float pitch) { if (pitch > 0.0f) { int intPitch = (int)(pitch * 100);

我通过设置音调和语速“创建”了一个定制的谷歌TTS语音

我为pitch选择的值为负(-6.4),我想在我的Android应用程序中使用精确的值

但是,
TextToSpeech.setPitch(float)
不能接受负值。以下是android.speech.tts.TextToSeech中的代码:

public int setPitch(float pitch) {
  if (pitch > 0.0f) {
    int intPitch = (int)(pitch * 100);
    if (intPitch > 0) {
      synchronized (mStartLock) {
        mParams.putInt(Engine.KEY_PARAM_PITCH, intPitch);
      }
      return SUCCESS;
    }
  }
  return ERROR;
}
我需要一些帮助来确定等价于-6.4的等价正值。似乎我不能简单地使用web界面上的相对比例[-20,20](默认值:0)和Android库中的[25400](默认值:100)来推断该值。后者来自
com.android.settings.tts.TextToSpeechSettings
,可从以下网址获得:


谢谢您的时间。

我不确定默认的0(web界面)如何等于100(android库),但这个公式可能会起作用

您可以尝试使用以下公式:

A_MIN_SPEECH_PITCH=-20

A_MAX_SPEECH_PITCH=20

B_MIN_SPEECH_PITCH=25

B_MAX_SPEECH_PITCH=400

语音音高=//所需音高

b_speech_pitch=(b_MAX_speech_pitch-b_MIN_speech_pitch)*((a_speech_pitch-a_MIN_speech_pitch)/(a_MAX_speech_pitch-a_MIN_speech_pitch))+b_MIN_speech_pitch

测试用例#1

a_演讲_音高=-20

音高=(400-25)*(-20-(-20))/(20-(-20))+25=25

测试用例#2

a_语音_音高=0

音高=(400-25)*(0-(-20))/(20-(-20))+25=212.5

测试用例#3

a_语音_音高=20

音高=(400-25)*(20-(-20))/(20-(-20))+25=400

测试用例4

a_语音_音高=-6.4


b_speech_pitch=(400-25)*((-6.4-(-20))/(20-(-20))+25=152.5

谢谢你的尝试,但如上所述,我不能像你那样简单地推断。这似乎不存在线性关系。在我的例子中,0.5(50)音高听起来非常接近-6.4。
    /**
     * Speech pitch value. TTS pitch value varies from 25 to 400, where 100 is the value for normal
     * pitch. The max pitch value is set to 400, based on feedback from users and the GoogleTTS
     * pitch variation range. The range for pitch is not set in stone and should be readjusted based
     * on user need. This value should be kept in sync with the max value set in tts_settings xml.
     */
    private static final int MAX_SPEECH_PITCH = 400;
    private static final int MIN_SPEECH_PITCH = 25;