-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.cs
55 lines (44 loc) · 1.16 KB
/
test.cs
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
using System;
using System.Runtime.InteropServices;
namespace HelloWorldApplication {
public struct GoString
{
public string msg;
public long len;
public GoString(string msg, long len)
{
this.msg = msg;
this.len = len;
}
}
class HelloWorld {
[DllImport("libspeechdwrapper.so")]
private static extern int Initialize();
[DllImport("libspeechdwrapper.so")]
private static extern int Speak(GoString text, bool interrupt);
[DllImport("libspeechdwrapper.so")]
private static extern int Close();
private static bool initialized = false;
static void Main(string[] args) {
// To Initialize
int res = Initialize();
if(res==1)
initialized = true;
// To Speak
if(initialized){
string msg = "Hello from C#!";
GoString str = new GoString(msg, msg.Length);
Speak(str, false);
msg = "I interrupted";
str.msg = msg;
str.len = msg.Length;
Speak(str, true);
}
// To close. IMPORTANT!!
if(initialized){
Close();
initialized = false;
}
}
}
}