Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

56
LINES

< > BotCompany Repo | #1027093 // Android Raspi Bridge [voice output only]

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (6000L/40K/136K).

!7

set flag Android. set flag NoAWT.

import android.media.*;
import android.content.*;

static int bufferSize = 8192;
static int maxAudioQueueSize = 50;

// raspi home, X20
static LS ips = ll("192.168.2.165", "192.168.43.244");

static AudioManager am;
static AudioRecord recorder;
static new L<StefansOS_ConnectToServer> senders;
static new L<Q> qSendAudio;
static new Q qVoiceOut;
static bool connected;

p {
  androidSay_keepEngine = true;
  //set androidSay_keepEngine_verbose;
  set androidSay_keepEngine_inCall;
  
  for (S ip : ips) {
    print("Connecting to " + ip);
    new StefansOS_ConnectToServer sender;
    sender.server = ip;
    sender.onLine = voidfunc(S s) {
      final new Matches m;
      if (startsWith_trim(s, "voiceOutput:", m))
        say(m.rest());
    };
    sender.tryToConnect = () -> !connectToServer_anyConnected(senders);
    sender.startWithSubs("voiceOutput");
    senders.add(sender);
    qSendAudio.add(new Q);
  }
  
  doEvery(1.0,r {
    if (connectToServer_anyConnected(senders) != connected) {
      connected = !connected;
      say(connected ? "Connected" : "Lost connection");
    }
  });
}

svoid cleanMeUp {
  dispose senders;
}

svoid say(S s) {
  print("> " + s);
  addToQWithMaxSize_verbose(5, +qVoiceOut, r { androidSayInEnglish(s); });
}

Author comment

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: 190 / 289
Version history: 3 change(s)
Referenced in: