Skip to content

Commit 316f37c

Browse files
committed
add public string for the test speech and voiceid
1 parent e367de4 commit 316f37c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Assets/Scenes/espeak.unity

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ MonoBehaviour:
223223
m_Script: {fileID: 11500000, guid: 0896d1324347bd349886948e2acc0cbe, type: 3}
224224
m_Name:
225225
m_EditorClassIdentifier:
226+
sayAtStart: Welcome!
226227
--- !u!4 &548749181
227228
Transform:
228229
m_ObjectHideFlags: 0
@@ -290,6 +291,7 @@ MonoBehaviour:
290291
m_Script: {fileID: 11500000, guid: 8b7423e13850ebd41a515edd899b7985, type: 3}
291292
m_Name:
292293
m_EditorClassIdentifier:
294+
voiceID: Tweaky
293295
--- !u!4 &1665498523
294296
Transform:
295297
m_ObjectHideFlags: 0

Assets/Scripts/Speech.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace UnityLibrary
1212
[DefaultExecutionOrder(-100)]
1313
public class Speech : MonoBehaviour
1414
{
15+
public string voiceID = "Tweaky";
16+
1517
// singleton isntance
1618
public static Speech instance;
1719

@@ -30,7 +32,6 @@ void Awake()
3032
Client.Initialize(datafolder);
3133

3234
// select voice
33-
string voiceID = "Tweaky";
3435
var setvoice = Client.SetVoiceByName(voiceID);
3536
if (setvoice == false) Debug.Log("Failed settings voice: " + voiceID);
3637

@@ -71,10 +72,10 @@ void SpeakerThread()
7172
// adds string to TTS queue
7273
public void Say(string msg)
7374
{
74-
if (isClosing == false && isRunning == true)
75-
{
76-
messages.Enqueue(msg);
77-
}
75+
if (isClosing == true || isRunning == false) return;
76+
if (string.IsNullOrEmpty(msg)) return;
77+
78+
messages.Enqueue(msg);
7879
}
7980

8081
private void OnDestroy()

Assets/Scripts/TestSpeech.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
public class TestSpeech : MonoBehaviour
55
{
6+
public string sayAtStart = "Welcome!";
7+
68
// Start is called before the first frame update
79
void Start()
810
{
911
// TEST speech
10-
Speech.instance.Say("Welcome!");
12+
Speech.instance.Say(sayAtStart);
1113
}
1214

1315
// Update is called once per frame

0 commit comments

Comments
 (0)