private void ButtonPlayToFile_Click(object sender, EventArgs e) { if (CheckTextIsEmpty()) { return; } SaveFileDialog fDlg = new SaveFileDialog(); //fDlg.Filter = "Wave File(*.wav)|*.wav|All File(*.*)|*.*"; if (iFileFormat == Jtts.FORMAT_WAV || iFileFormat == Jtts.FORMAT_WAV_8K8B || iFileFormat == Jtts.FORMAT_WAV_8K16B || iFileFormat == Jtts.FORMAT_WAV_16K8B || iFileFormat == Jtts.FORMAT_WAV_16K16B || iFileFormat == Jtts.FORMAT_WAV_11K8B || iFileFormat == Jtts.FORMAT_WAV_11K16B || ((iFileFormat == Jtts.FORMAT_ALAW_8K || iFileFormat == Jtts.FORMAT_uLAW_8K) && (iFileHead == Jtts.PLAYTOFILE_ADDHEAD))) { fDlg.Filter = "Wave File (*.wav)|*.wav|All Files(*.*)|*.*"; } else if (iFileFormat == Jtts.FORMAT_VOX_6K || iFileFormat == Jtts.FORMAT_VOX_8K) { fDlg.Filter = "Vox File (*.vox)|*.vox|All Files(*.*)|*.*"; } else { fDlg.Filter = "ALaw or uLaw File (*.law)|*.law|All Files(*.*)|*.*"; } if (DialogResult.OK == fDlg.ShowDialog(this)) { Jtts.JTTS_CONFIG config = new Jtts.JTTS_CONFIG(); int iErr = Jtts.jTTS_Get(out config); Jtts.jTTS_PlayToFile(textBoxContent.Text, fDlg.FileName, 0, ref config, 0, 0, 0); } }
//Initialize dialog's state according to in-param[config]. public void SetJttsConfig(Jtts.JTTS_CONFIG config) { int i = 0; //Get all voice and add to "comboBoxVoice". int iVoiceCount = Jtts.jTTS_GetVoiceCount(); int iDefaultVoiceIndex = 0; //Index of default voice. for (i = 0; i < iVoiceCount; i++) { Jtts.JTTS_VOICEATTRIBUTE vAtt = new InfoQuick.SinoVoice.Tts.Jtts.JTTS_VOICEATTRIBUTE(); Jtts.jTTS_GetVoiceAttribute(i, out vAtt); Jtts.JTTS_LANGATTRIBUTE lAtt = new InfoQuick.SinoVoice.Tts.Jtts.JTTS_LANGATTRIBUTE(); Jtts.jTTS_GetLangAttributeByValue(vAtt.nLanguage, out lAtt); string strVoiceDescribe = vAtt.szName + '(' + lAtt.szName + " " + strGender[vAtt.nGender] + ')'; comboBoxVoice.Items.Add(strVoiceDescribe); //Get index of default voice. if (config.szVoiceID == vAtt.szVoiceID) { iDefaultVoiceIndex = i; } } //Set default voice. comboBoxVoice.SelectedIndex = iDefaultVoiceIndex; comboBoxDomain.SelectedIndex = config.nDomain; comboBoxCodePage.SelectedIndex = CodePageFromValueToIndex(config.nCodePage); comboBoxDigital.SelectedIndex = config.nDigitMode; comboBoxEnglish.SelectedIndex = config.nEngMode; comboBoxTag.SelectedIndex = config.nTagMode; trackBarVolume.Value = config.nVolume; trackBarSpeed.Value = config.nSpeed; trackBarPitch.Value = config.nPitch; checkBoxPunctuation.Checked = ((config.nPuncMode & (short)0x01) != 0)? true : false; checkBoxReturnCutSentence.Checked = ((config.nPuncMode & (short)0x02) != 0)? true : false; }
public void GetJttsConfig(ref Jtts.JTTS_CONFIG config) { config.szVoiceID = textBoxVoiceID.Text; config.nDomain = (short)comboBoxDomain.SelectedIndex; config.nCodePage = (ushort)CodePageFromIndexToValue(comboBoxCodePage.SelectedIndex); config.nDigitMode = (short)comboBoxDigital.SelectedIndex; config.nEngMode = (short)comboBoxEnglish.SelectedIndex; config.nTagMode = (short)comboBoxTag.SelectedIndex; config.nVolume = (short)trackBarVolume.Value; config.nSpeed = (short)trackBarSpeed.Value; config.nPitch = (short)trackBarPitch.Value; config.nPuncMode = 0; if (checkBoxPunctuation.Checked) { config.nPuncMode |= (short)0x01; } if (checkBoxReturnCutSentence.Checked) { config.nPuncMode |= (short)0x02; } }