Libraryless. Click here for Pure Java version (6000L/40K/136K).
1 | !7 |
2 | |
3 | set flag Android. set flag NoAWT. |
4 | |
5 | import android.media.*; |
6 | import android.content.*; |
7 | |
8 | static int bufferSize = 8192; |
9 | static int maxAudioQueueSize = 50; |
10 | |
11 | // raspi home, X20 |
12 | static LS ips = ll("192.168.2.165", "192.168.43.244"); |
13 | |
14 | static AudioManager am; |
15 | static AudioRecord recorder; |
16 | static new L<StefansOS_ConnectToServer> senders; |
17 | static new L<Q> qSendAudio; |
18 | static new Q qVoiceOut; |
19 | static bool connected; |
20 | |
21 | p { |
22 | androidSay_keepEngine = true; |
23 | //set androidSay_keepEngine_verbose; |
24 | set androidSay_keepEngine_inCall; |
25 | |
26 | for (S ip : ips) { |
27 | print("Connecting to " + ip); |
28 | new StefansOS_ConnectToServer sender; |
29 | sender.server = ip; |
30 | sender.onLine = voidfunc(S s) { |
31 | final new Matches m; |
32 | if (startsWith_trim(s, "voiceOutput:", m)) |
33 | say(m.rest()); |
34 | }; |
35 | sender.tryToConnect = () -> !connectToServer_anyConnected(senders); |
36 | sender.startWithSubs("voiceOutput"); |
37 | senders.add(sender); |
38 | qSendAudio.add(new Q); |
39 | } |
40 | |
41 | doEvery(1.0,r { |
42 | if (connectToServer_anyConnected(senders) != connected) { |
43 | connected = !connected; |
44 | say(connected ? "Connected" : "Lost connection"); |
45 | } |
46 | }); |
47 | } |
48 | |
49 | svoid cleanMeUp { |
50 | dispose senders; |
51 | } |
52 | |
53 | svoid say(S s) { |
54 | print("> " + s); |
55 | addToQWithMaxSize_verbose(5, +qVoiceOut, r { androidSayInEnglish(s); }); |
56 | } |
Began life as a copy of #1027055
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, odkhaoglnmdk, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027093 |
Snippet name: | Android Raspi Bridge [voice output only] |
Eternal ID of this version: | #1027093/4 |
Text MD5: | 1abe64ba4d22d891c005cd3fd2985b75 |
Transpilation MD5: | 4338dbc9dc1fcbb107804e4a24b9d2a0 |
Author: | stefan |
Category: | javax / android |
Type: | JavaX source code (Android) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-17 18:49:57 |
Source code size: | 1346 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 189 / 288 |
Version history: | 3 change(s) |
Referenced in: | [show references] |