Skip to content

Commit

Permalink
Merge pull request #406 from wbonbon/master
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
wbonbon authored Aug 4, 2024
2 parents fb159de + 44d4f41 commit d8a3dc2
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 20 deletions.
2 changes: 1 addition & 1 deletion source/@MasterVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10.3.6
v10.3.7
4 changes: 2 additions & 2 deletions source/ACT.Hojoring.Common/Version.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;

[assembly: AssemblyVersion("10.3.0.6")]
[assembly: AssemblyFileVersion("10.3.0.6")]
[assembly: AssemblyVersion("10.3.0.7")]
[assembly: AssemblyFileVersion("10.3.0.7")]
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ public void Speak(
{
return;
}
GoogleCloudTextToSpeechConfig config;
switch (voicePalette)
{
case VoicePalettes.Default:
config = Settings.Default.GoogleCloudTextToSpeechSettings;
break;
case VoicePalettes.Ext1:
config = Settings.Default.GoogleCloudTextToSpeechSettingsExt1;
break;
case VoicePalettes.Ext2:
config = Settings.Default.GoogleCloudTextToSpeechSettingsExt2;
break;
case VoicePalettes.Ext3:
config = Settings.Default.GoogleCloudTextToSpeechSettingsExt3;
break;
default:
config = Settings.Default.GoogleCloudTextToSpeechSettings;
break;
}

var client = GoogleCloudTextToSpeechConfig.TTSClient;
if (client == null)
Expand All @@ -62,7 +81,7 @@ public void Speak(
var wave = this.GetCacheFileName(
Settings.Default.TTS,
text.Replace(Environment.NewLine, "+"),
Settings.Default.GoogleCloudTextToSpeechSettings.ToString());
config.ToString());

this.CreateWaveWrapper(wave, () =>
{
Expand All @@ -74,25 +93,25 @@ public void Speak(

VoiceSelectionParams voice = new VoiceSelectionParams
{
LanguageCode = Settings.Default.GoogleCloudTextToSpeechSettings.LanguageCode,
Name = Settings.Default.GoogleCloudTextToSpeechSettings.Name,
LanguageCode = config.LanguageCode,
Name = config.Name,
};

AudioConfig config = new AudioConfig
AudioConfig audioconfig = new AudioConfig
{
AudioEncoding = AudioEncoding.Linear16,
VolumeGainDb = Settings.Default.GoogleCloudTextToSpeechSettings.VolumeGainDb,
Pitch = Settings.Default.GoogleCloudTextToSpeechSettings.Pitch,
SpeakingRate = Settings.Default.GoogleCloudTextToSpeechSettings.SpeakingRate,
SampleRateHertz = Settings.Default.GoogleCloudTextToSpeechSettings.SampleRateHertz,
VolumeGainDb = config.VolumeGainDb,
Pitch = config.Pitch,
SpeakingRate = config.SpeakingRate,
SampleRateHertz = config.SampleRateHertz,
};

// 音声合成リクエストを送信する
var response = client.SynthesizeSpeech(new SynthesizeSpeechRequest
{
Input = input,
Voice = voice,
AudioConfig = config
AudioConfig = audioconfig
});

// 合成した音声をファイルに書き出す
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void Speak(
case VoicePalettes.Ext2:
config = Settings.Default.HOYASettingsExt2;
break;
case VoicePalettes.Ext3:
config = Settings.Default.HOYASettingsExt3;
break;
default:
config = Settings.Default.HOYASettings;
break;
Expand All @@ -74,7 +77,7 @@ public void Speak(
this.CreateWaveWrapper(wave, () =>
{
if (string.IsNullOrWhiteSpace(
Settings.Default.HOYASettings.APIKey))
config.APIKey))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,34 @@ public void Speak(
return;
}

OpenJTalkConfig config;
switch (voicePalette)
{
case VoicePalettes.Default:
config = Settings.Default.OpenJTalkSettings;
break;
case VoicePalettes.Ext1:
config = Settings.Default.OpenJTalkSettingsExt1;
break;
case VoicePalettes.Ext2:
config = Settings.Default.OpenJTalkSettingsExt2;
break;
case VoicePalettes.Ext3:
config = Settings.Default.OpenJTalkSettingsExt3;
break;
default:
config = Settings.Default.OpenJTalkSettings;
break;
}

// テキストをユーザ辞書で置き換える
text = this.ReplaceByUserDictionary(text);

// 現在の条件をハッシュ化してWAVEファイル名を作る
var wave = this.GetCacheFileName(
Settings.Default.TTS,
text.Replace(Environment.NewLine, "+"),
this.Config.ToString());
config.ToString());

this.CreateWaveWrapper(wave, () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,31 @@ public void Speak(
{
return;
}
PollyConfigs config;
switch (voicePalette)
{
case VoicePalettes.Default:
config = Settings.Default.PollySettings;
break;
case VoicePalettes.Ext1:
config = Settings.Default.PollySettingsExt1;
break;
case VoicePalettes.Ext2:
config = Settings.Default.PollySettingsExt2;
break;
case VoicePalettes.Ext3:
config = Settings.Default.PollySettingsExt3;
break;
default:
config = Settings.Default.PollySettingsExt1;
break;
}

// 現在の条件をハッシュ化してWAVEファイル名を作る
var wave = this.GetCacheFileName(
Settings.Default.TTS,
text.Replace(Environment.NewLine, "+"),
Settings.Default.PollySettings.ToString(),
config.ToString(),
true);

this.CreateWaveWrapper(wave, () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,39 @@ public void Speak(
return;
}

SAPI5Configs config;
switch (voicePalette)
{
case VoicePalettes.Default:
config = Settings.Default.SAPI5Settings;
break;
case VoicePalettes.Ext1:
config = Settings.Default.SAPI5SettingsExt1;
break;
case VoicePalettes.Ext2:
config = Settings.Default.SAPI5SettingsExt2;
break;
case VoicePalettes.Ext3:
config = Settings.Default.SAPI5SettingsExt3;
break;
default:
config = Settings.Default.SAPI5Settings;
break;
}

// 現在の条件をハッシュ化してWAVEファイル名を作る
var wave = this.GetCacheFileName(
Settings.Default.TTS,
text,
this.Config.ToString());
config.ToString());

this.CreateWaveWrapper(wave, () =>
{
using (var fs = new FileStream(wave, FileMode.Create))
using (var synth = new SpeechSynthesizer())
{
// VOICEを設定する
var voice = this.GetSynthesizer(this.Config.VoiceID);
var voice = this.GetSynthesizer(config.VoiceID);
if (voice == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,38 @@ public void Speak(
return;
}

YukkuriConfig config;
switch (voicePalette)
{
case VoicePalettes.Default:
config = Settings.Default.YukkuriSettings;
break;
case VoicePalettes.Ext1:
config = Settings.Default.YukkuriSettingsExt1;
break;
case VoicePalettes.Ext2:
config = Settings.Default.YukkuriSettingsExt2;
break;
case VoicePalettes.Ext3:
config = Settings.Default.YukkuriSettingsExt3;
break;
default:
config = Settings.Default.YukkuriSettings;
break;
}

// 現在の条件をハッシュ化してWAVEファイル名を作る
var wave = this.GetCacheFileName(
Settings.Default.TTS,
text.Replace(Environment.NewLine, "+"),
Settings.Default.YukkuriSettings.ToString());
config.ToString());

this.CreateWaveWrapper(wave, () =>
{
// よみがなに変換する
var tts = text;

if (Settings.Default.YukkuriSettings.UseKanji2Koe)
if (config.UseKanji2Koe)
{
tts = this.ConvertToPhoneticByKanji2Koe(tts);
}
Expand All @@ -99,7 +119,7 @@ public void Speak(
AquesTalk.Instance.TextToWave(
tts,
wave,
Settings.Default.YukkuriSettings.ToParameter());
config.ToParameter());
});

// 再生する
Expand Down

0 comments on commit d8a3dc2

Please sign in to comment.