Skip to content

Commit 81c5521

Browse files
committed
add playback of audio files in text to speech options
1 parent 4c4fe9f commit 81c5521

10 files changed

+736
-81
lines changed

Controls/TextToSpeech.Designer.cs

+141-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Controls/TextToSpeech.cs

+65-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public TextToSpeech(CameraWindow cw = null)
1717
CW = cw;
1818
Text = LocRm.GetString("TextToSpeech");
1919
button1.Text = LocRm.GetString("OK");
20+
button3.Text = LocRm.GetString("OK");
2021
}
2122

2223
public override sealed string Text
@@ -27,7 +28,8 @@ public override sealed string Text
2728

2829
private void TextToSpeech_Load(object sender, EventArgs e)
2930
{
30-
PopSentences();
31+
PopSentences();
32+
PopPaths();
3133
}
3234

3335
private void button1_Click(object sender, EventArgs e)
@@ -80,16 +82,76 @@ private void PopSentences()
8082

8183
private void ddlSay_KeyPress(object sender, KeyPressEventArgs e)
8284
{
83-
if (e.KeyChar == (char) Keys.Return)
85+
if (e.KeyChar == (char)Keys.Return)
8486
{
8587
Say();
8688
e.Handled = true;
8789
}
8890
}
8991

90-
private void ddlSay_SelectedIndexChanged(object sender, EventArgs e)
92+
private void ddlPath_KeyPress(object sender, KeyPressEventArgs e)
9193
{
94+
if (e.KeyChar == (char)Keys.Return)
95+
{
96+
Play();
97+
e.Handled = true;
98+
}
99+
}
100+
101+
private void button2_Click(object sender, EventArgs e)
102+
{
103+
if (dlgOpen.ShowDialog(this) == DialogResult.OK)
104+
{
105+
ddlPath.Text = dlgOpen.FileName;
106+
}
107+
}
92108

109+
private void button3_Click(object sender, EventArgs e)
110+
{
111+
Play();
112+
}
113+
114+
private void Play()
115+
{
116+
var p = ddlPath.Text;
117+
if (!string.IsNullOrEmpty(p))
118+
{
119+
AudioSynth.Play(p, CW);
120+
CW.LogToPlugin("Play: " + p);
121+
var _p = new List<string> { p };
122+
foreach (var i in ddlPath.Items)
123+
{
124+
if (!_p.Contains(i) && !string.IsNullOrEmpty(i.ToString()))
125+
_p.Add(i.ToString());
126+
}
127+
128+
var x = "";
129+
int j = 0;
130+
foreach (string s in _p)
131+
{
132+
if (j < 10)
133+
x += s + "|";
134+
else
135+
{
136+
break;
137+
}
138+
j++;
139+
}
140+
x = x.Trim('|');
141+
MainForm.Conf.PlayPaths = x;
142+
PopPaths();
143+
}
144+
}
145+
146+
private void PopPaths()
147+
{
148+
ddlPath.Items.Clear();
149+
var s = MainForm.Conf.PlayPaths.Split('|');
150+
foreach (var p in s)
151+
{
152+
if (!string.IsNullOrEmpty(p))
153+
ddlPath.Items.Add(p);
154+
}
93155
}
94156
}
95157
}

Controls/TextToSpeech.resx

+6
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,10 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121+
<value>17, 17</value>
122+
</metadata>
123+
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
124+
<value>62</value>
125+
</metadata>
120126
</root>

0 commit comments

Comments
 (0)