-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTTS.cs
More file actions
93 lines (69 loc) · 2.17 KB
/
TTS.cs
File metadata and controls
93 lines (69 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TTS : MonoBehaviour
{
Button b;
Text t;
private AndroidJavaObject tts = null;
private AndroidJavaObject activityContext = null;
void Start()
{
b = GameObject.Find("Button").GetComponent<Button>();
t = GameObject.Find("Text").GetComponent<Text>();
b.onClick.AddListener(ac);
t.text = "started";
}
public void ac()
{
try
{
t.text = "actions";
// if (tts == null)
// {
t.text = "IFIN1";
using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
t.text = "USEACT";
}
using (AndroidJavaClass pluginClass = new AndroidJavaClass("com.example.ttsunity.MainClass"))
{
t.text = "USEPLGU";
// if (pluginClass != null)
// {
t.text = "INSIDEPLUFID";
tts = pluginClass.CallStatic<AndroidJavaObject>("instance");
tts.Call("setContext", activityContext);
activityContext.Call("runOnUiThread", new AndroidJavaRunnable(() =>
{
t.text = "INSIDEPLUFIDSSS";
String speak = "Hi How are you";
String aa = tts.Call<String>("getText", speak);
t.text = aa;
}));
t.text = "INSIDEPLUFIDENDS";
// }
// else
// {
// t.text = "Error2";
//}
}
//}
//else
//{
// t.text = "Error1";
//}
}
catch (Exception e)
{
t.text = e.Message;
}
}
// Update is called once per frame
void Update()
{
}
}