Skip to content

Commit

Permalink
プリセット形式で
Browse files Browse the repository at this point in the history
  • Loading branch information
opera7133 committed Mar 17, 2023
1 parent ebc84d0 commit 3f66751
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 38 deletions.
1 change: 1 addition & 0 deletions dll/check.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text.RegularExpressions;
using AI.Talk.Editor.Api;
// csc /r:"C:\Program Files/\AI/\AIVoice/\AIVoiceEditor/\AI.Talk.Editor.Api.dll"

Expand Down
Binary file modified dll/check.exe
Binary file not shown.
Binary file modified dll/client.exe
Binary file not shown.
44 changes: 33 additions & 11 deletions dll/server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public string GetCharList()
}
}

// arg: string
// 形式:"ボイス名,音量,話速,高さ,抑揚,短ポーズ(ms),長ポーズ(ms),喜び,怒り,悲しみ"
// 例 :"結月 ゆかり,1,1.2,1,1,150,370,0,0,0,こんにちは"
public void talk(string arg)
{
pTtsControl = new TtsControl();
Expand All @@ -229,23 +232,42 @@ public void talk(string arg)
char[] sep = new char[] { ',' };
string[] head = arg.Split(sep, 2);
string CharPreset = head[0];
pTtsControl.CurrentVoicePresetName = CharPreset;
string[] presets = pTtsControl.VoicePresetNames;
bool result = Array.Exists(presets, preset => preset == CharPreset + " 伺か一時プリセット");
if (!result)
{
Match VoiceName = Regex.Match(pTtsControl.GetVoicePreset(CharPreset), "\"VoiceName\":\"([^\"]*)\"");
var initPreset = new Dictionary<string, string>(){
{"PresetName", CharPreset + " 伺か一時プリセット"},
{"VoiceName", VoiceName.Groups[1].Value},
};
pTtsControl.AddVoicePreset(JsonConvert.SerializeObject(initPreset));
}
pTtsControl.CurrentVoicePresetName = CharPreset + " 伺か一時プリセット";
Program.TalkingChar = CharPreset;
Console.WriteLine("Char = " + CharPreset);

string[] Options = arg.Split(sep, 6);
string[] Options = arg.Split(sep, 11);

//共通項が4
var masterControl = new Dictionary<string, Double>(){
{"Volume", Convert.ToDouble(Options[1])},
{"Speed", Convert.ToDouble(Options[2])},
{"Pitch", Convert.ToDouble(Options[3])},
{"PitchRange", Convert.ToDouble(Options[4])}
};
pTtsControl.MasterControl = JsonConvert.SerializeObject(masterControl, Formatting.Indented);
//共通項が9
string CurrentPreset = "{";
//多次元連想配列の作り方がわからない
CurrentPreset += "\"PresetName\":\"" + CharPreset + " 伺か一時プリセット" + "\",";
CurrentPreset += "\"Volume\":" + Convert.ToDouble(Options[1]) + ",";
CurrentPreset += "\"Speed\":" + Convert.ToDouble(Options[2]) + ",";
CurrentPreset += "\"Pitch\":" + Convert.ToDouble(Options[3]) + ",";
CurrentPreset += "\"PitchRange\":" + Convert.ToDouble(Options[4]) + ",";
CurrentPreset += "\"MiddlePause\":" + Convert.ToDouble(Options[5]) + ",";
CurrentPreset += "\"LongPause\":" + Convert.ToDouble(Options[6]) + ",";
CurrentPreset += "\"Styles\":[{\"Name\":\"J\", \"Value\":" + Convert.ToDouble(Options[7]) + "},";
CurrentPreset += "{\"Name\":\"A\", \"Value\":" + Convert.ToDouble(Options[8]) + "},";
CurrentPreset += "{\"Name\":\"S\", \"Value\":" + Convert.ToDouble(Options[9]) + "}]";
CurrentPreset += "}";

pTtsControl.SetVoicePreset(CurrentPreset);

string[] MySep = { "MySep" };
string VoiceText = Options[5];
string VoiceText = Options[10];

//バルーン空打ち対策
string CheckText = VoiceText;
Expand Down
Binary file modified dll/server.exe
Binary file not shown.
99 changes: 72 additions & 27 deletions main.uka
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,29 @@ OnOtherGhostTalk {
_Char = TalkCharacter( TalkingGhost )
if ( _Char != "" ) {
_noSpaceChar = REPLACE(_Char, " ", "")
EVAL( "_Volume = AIVOICE.%(_noSpaceChar).Volume" )
EVAL( "_Speed = AIVOICE.%(_noSpaceChar).Speed" )
EVAL( "_Pitch = AIVOICE.%(_noSpaceChar).Pitch" )
EVAL( "_PitchRange = AIVOICE.%(_noSpaceChar).PitchRange" )

if ( _Volume == "" ) { _Volume = 1 }
if ( _Speed == "" ) { _Speed = 1 }
if ( _Pitch == "" ) { _Pitch = 1 }
if ( _PitchRange == "" ) { _PitchRange = 1 }
EVAL( "_Volume = AIVOICE.%(_noSpaceChar).Volume" )
EVAL( "_Speed = AIVOICE.%(_noSpaceChar).Speed" )
EVAL( "_Pitch = AIVOICE.%(_noSpaceChar).Pitch" )
EVAL( "_PitchRange = AIVOICE.%(_noSpaceChar).PitchRange" )
EVAL( "_MiddlePause = AIVOICE.%(_noSpaceChar).MiddlePause" )
EVAL( "_LongPause = AIVOICE.%(_noSpaceChar).LongPause" )
EVAL( "_StyleJ = AIVOICE.%(_noSpaceChar).StyleJ" )
EVAL( "_StyleA = AIVOICE.%(_noSpaceChar).StyleA" )
EVAL( "_StyleS = AIVOICE.%(_noSpaceChar).StyleS" )

if ( _Volume == "" ) { _Volume = 1 }
if ( _Speed == "" ) { _Speed = 1.2 }
if ( _Pitch == "" ) { _Pitch = 1 }
if ( _PitchRange == "" ) { _PitchRange = 1 }
if ( _MiddlePause == "" ) { _MiddlePause = 150 }
if ( _LongPause == "" ) { _LongPause = 370 }
if ( _StyleJ == "" ) { _StyleJ = 0 }
if ( _StyleA == "" ) { _StyleA = 0 }
if ( _StyleS == "" ) { _StyleS = 0 }

_Script = reference[4]
_VoiceText = TalkText( _Script )
_args = "%(_Char),%(_Volume),%(_Speed),%(_Pitch),%(_PitchRange),%(_VoiceText)"
_args = "%(_Char),%(_Volume),%(_Speed),%(_Pitch),%(_PitchRange),%(_MiddlePause),%(_LongPause),%(_StyleJ),%(_StyleA),%(_StyleS),%(_VoiceText)"

//Char = _Char
//args = _args
Expand Down Expand Up @@ -173,9 +183,9 @@ TalkText {
//_text = RE_REPLACE( _text , '\\u' , "GhostName" )

// 名前置き換え
//_text = RE_REPLACE( _text , '\\![embed,On_一人称]' , "\![embed,On_一人称]")
//_text = RE_REPLACE( _text , '\\!\[embed,On_ユーザ名\]' , "\![embed,On_ユーザ名]")

//_text = REPLACE( _text , '\![embed,On_一人称]' , "")
//_text = REPLACE( _text , '\![embed,On_ユーザ名]' , "マスター")
//サクラスクリプト除去
_text = RE_REPLACE( _text , '\\__.\[.*?\]' , "" )
_text = RE_REPLACE( _text , '\\_.\[.*?\]' , "" )
Expand Down Expand Up @@ -250,6 +260,8 @@ TalkText {
_text = REPLACE( _text , '!?!?' , '!?' )
_text = REPLACE( _text , '?!?!' , '?!' )

_text = REPLACE( _text , '-----------', '')

if (SUBSTR(_text,0,1) == "。") {
_text = ERASE(_text,0,1)
}
Expand All @@ -263,19 +275,37 @@ OnAIVOICE.CharConfigMenu {
_Char = reference[0]

_noSpaceChar = REPLACE(_Char, " ", "")
EVAL( "_Volume = AIVOICE.%(_noSpaceChar).Volume" )
EVAL( "_Speed = AIVOICE.%(_noSpaceChar).Speed" )
EVAL( "_Pitch = AIVOICE.%(_noSpaceChar).Pitch" )
EVAL( "_PitchRange = AIVOICE.%(_noSpaceChar).PitchRange" )
if ( _Volume == "" ) { _Volume = 1 }
if ( _Speed == "" ) { _Speed = 1.2 }
if ( _Pitch == "" ) { _Pitch = 1 }
if ( _PitchRange == "" ) { _PitchRange = 1 }
EVAL( "_Volume = AIVOICE.%(_noSpaceChar).Volume" )
EVAL( "_Speed = AIVOICE.%(_noSpaceChar).Speed" )
EVAL( "_Pitch = AIVOICE.%(_noSpaceChar).Pitch" )
EVAL( "_PitchRange = AIVOICE.%(_noSpaceChar).PitchRange" )
EVAL( "_MiddlePause = AIVOICE.%(_noSpaceChar).MiddlePause" )
EVAL( "_LongPause = AIVOICE.%(_noSpaceChar).LongPause" )
EVAL( "_StyleJ = AIVOICE.%(_noSpaceChar).StyleJ" )
EVAL( "_StyleA = AIVOICE.%(_noSpaceChar).StyleA" )
EVAL( "_StyleS = AIVOICE.%(_noSpaceChar).StyleS" )

if ( _Volume == "" ) { _Volume = 1 }
if ( _Speed == "" ) { _Speed = 1.2 }
if ( _Pitch == "" ) { _Pitch = 1 }
if ( _PitchRange == "" ) { _PitchRange = 1 }
if ( _MiddlePause == "" ) { _MiddlePause = 150 }
if ( _LongPause == "" ) { _LongPause = 370 }
if ( _StyleJ == "" ) { _StyleJ = 0 }
if ( _StyleA == "" ) { _StyleA = 0 }
if ( _StyleS == "" ) { _StyleS = 0 }

_AIVOICE.MainOptions = "/
\![*]\q[%(_Volume ) : Volume ,OnAIVOICE.CharOption,%(_Char),Volume]\n/
\![*]\q[%(_Speed ) : Speed ,OnAIVOICE.CharOption,%(_Char),Speed]\n/
\![*]\q[%(_Pitch ) : Pitch ,OnAIVOICE.CharOption,%(_Char),Pitch]\n/
\![*]\q[%(_PitchRange) : PitchRange,OnAIVOICE.CharOption,%(_Char),PitchRange]\n/
\![*]\q[%(_Volume ) : Volume ,OnAIVOICE.CharOption,%(_Char),Volume]\n/
\![*]\q[%(_Speed ) : Speed ,OnAIVOICE.CharOption,%(_Char),Speed]\n/
\![*]\q[%(_Pitch ) : Pitch ,OnAIVOICE.CharOption,%(_Char),Pitch]\n/
\![*]\q[%(_PitchRange ) : PitchRange ,OnAIVOICE.CharOption,%(_Char),PitchRange]\n/
\![*]\q[%(_MiddlePause) : MiddlePause,OnAIVOICE.CharOption,%(_Char),MiddlePause]\n/
\![*]\q[%(_LongPause ) : LongPause ,OnAIVOICE.CharOption,%(_Char),LongPause]\n/
-----------\n/
\![*]\q[%(_StyleJ ) : StyleJ ,OnAIVOICE.CharOption,%(_Char),StyleJ]\n/
\![*]\q[%(_StyleA ) : StyleA ,OnAIVOICE.CharOption,%(_Char),StyleA]\n/
\![*]\q[%(_StyleS ) : StyleS ,OnAIVOICE.CharOption,%(_Char),StyleS]\n/
-----------\n"

////誰が誰にしゃべらせるか。,
Expand Down Expand Up @@ -332,9 +362,24 @@ OnAIVOICE.SetOption {
"0.5から2.0までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} elseif ( AIVOICE.Option == "PitchRange" && (_num < 0 || 2 < _num) ) {
"0.0から2.0までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} elseif ( AIVOICE.Option == "MiddlePause" && (_num < 80 || 500 < _num) ) {
"80から500までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} elseif ( AIVOICE.Option == "LongPause" && (_num < 80 || 2000 < _num) ) {
"80から2000までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} elseif ( AIVOICE.Option == "StyleJ" && (_num < 0 || 1 < _num) ) {
"0.0から1.0までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} elseif ( AIVOICE.Option == "StyleA" && (_num < 0 || 1 < _num) ) {
"0.0から1.0までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} elseif ( AIVOICE.Option == "StyleS" && (_num < 0 || 1 < _num) ) {
"0.0から1.0までの値を半角で入力してください。\![open,inputbox,OnAIVOICE.SetOption]"
} else {
_tempNum = (ROUND(_num*10))/10
EVAL( "AIVOICE.%(_noSpaceChar).%(AIVOICE.Option) = %(_tempNum)" )
if ( AIVOICE.Option == "MiddlePause" || AIVOICE.Option == "LongPause" ) {
_tempNum = ROUND(_num)
EVAL( "AIVOICE.%(_noSpaceChar).%(AIVOICE.Option) = %(_tempNum)" )
} else {
_tempNum = (ROUND(_num*100))/100
EVAL( "AIVOICE.%(_noSpaceChar).%(AIVOICE.Option) = %(_tempNum)" )
}
//確認のメニューはさっきのを呼びなおす
//設定に戻る。
//設定終了
Expand Down

0 comments on commit 3f66751

Please sign in to comment.