Skip to content

Commit eacd37c

Browse files
committed
updated to simple_frame_app 1.0.1
1 parent 4f84c95 commit eacd37c

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

lib/main.dart

+12-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'package:google_speech/google_speech.dart';
88
import 'package:logging/logging.dart';
99
import 'package:share_plus/share_plus.dart';
1010
import 'package:shared_preferences/shared_preferences.dart';
11-
import 'package:simple_frame_app/audio_data_response.dart';
12-
import 'package:simple_frame_app/tap_data_response.dart';
11+
import 'package:simple_frame_app/rx/audio.dart';
12+
import 'package:simple_frame_app/rx/tap.dart';
1313
import 'package:simple_frame_app/tx/code.dart';
1414
import 'package:simple_frame_app/tx/plain_text.dart';
1515
import 'package:simple_frame_app/text_utils.dart';
@@ -34,8 +34,8 @@ class MainAppState extends State<MainApp> with SimpleFrameAppState {
3434
hierarchicalLoggingEnabled = true;
3535
Logger.root.level = Level.INFO;
3636
Logger('Bluetooth').level = Level.OFF;
37-
Logger('AudioDR').level = Level.FINE;
38-
Logger('TapDR').level = Level.FINE;
37+
Logger('RxAudio').level = Level.FINE;
38+
Logger('RxTap').level = Level.FINE;
3939

4040
Logger.root.onRecord.listen((record) {
4141
debugPrint('${record.level.name}: [${record.loggerName}] ${record.time}: ${record.message}');
@@ -122,7 +122,7 @@ class MainAppState extends State<MainApp> with SimpleFrameAppState {
122122
try {
123123
// listen for double taps to start/stop transcribing
124124
_tapSubs?.cancel();
125-
_tapSubs = tapDataResponse(frame!.dataResponse, const Duration(milliseconds: 300))
125+
_tapSubs = RxTap().attach(frame!.dataResponse)
126126
.listen((taps) async {
127127
if (taps >= 2) {
128128
if (!_streaming) {
@@ -200,8 +200,10 @@ class MainAppState extends State<MainApp> with SimpleFrameAppState {
200200
await frame!.sendMessage(TxCode(msgCode: 0x30, value: 1));
201201

202202
try {
203+
// TODO put this object where I can call on it later to detach()
204+
var rxAudio = RxAudio(streaming: true);
203205
// the audio stream from Frame, which needs to be closed() to stop the streaming recognition
204-
_audioSampleStream = audioDataStreamResponse(frame!.dataResponse);
206+
_audioSampleStream = rxAudio.attach(frame!.dataResponse);
205207

206208
String prevText = '';
207209

@@ -238,7 +240,7 @@ class MainAppState extends State<MainApp> with SimpleFrameAppState {
238240
// but concatenate to the same string in our case, so don't update Frame display)
239241
if (currentText != prevText) { // TODO (&& Latin-only script?)
240242
// Frame can display 6 lines of plain text, so work out the text wrapping
241-
List<String> wrappedText = TextUtils.wrapTextSplit(currentText, 640, 4);
243+
List<String> wrappedText = TextUtils.wrapText(currentText, 640, 4);
242244

243245
// then send the bottom 6 lines joined with newlines as a single string
244246
// (they get split and drawn on the Lua side)
@@ -298,6 +300,9 @@ class MainAppState extends State<MainApp> with SimpleFrameAppState {
298300
Future<void> _stopRecognition() async {
299301
// tell Frame to stop streaming audio
300302
await frame!.sendMessage(TxCode(msgCode: 0x30, value: 0));
303+
304+
// TODO we should also be able to send
305+
// rxAudio.detach() to close the controller controlling our audio stream
301306
}
302307

303308
void _scrollToBottom() {

pubspec.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ packages:
444444
dependency: "direct main"
445445
description:
446446
name: simple_frame_app
447-
sha256: "15acfb97c95526143bdf9e77bb4bcc2ee839bafa526568beef1247ac6bc95ea0"
447+
sha256: "256d6a1b6a194745bdfe004e6016a871a4936cd92152067cbc656339b267cf3c"
448448
url: "https://pub.dev"
449449
source: hosted
450-
version: "0.0.9"
450+
version: "1.0.1"
451451
sky_engine:
452452
dependency: transitive
453453
description: flutter

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
sdk: flutter
1212
logging: ^1.2.0
1313
google_speech: ^5.3.0
14-
simple_frame_app: ^0.0.9
14+
simple_frame_app: ^1.0.1
1515
shared_preferences: ^2.3.2
1616
share_plus: ^10.1.0
1717

0 commit comments

Comments
 (0)