Skip to content

Commit f61809c

Browse files
committed
try to fix watch app
1 parent e1f8ce8 commit f61809c

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

lib/services/ai_service.dart

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ class AIService {
376376
final responseBuffer = StringBuffer();
377377
bool audioHeaderSent = false;
378378
bool hasReceivedAudio = false;
379-
bool usePhoneAudio = !_watchService.isConnected; // Track if we're using phone audio
379+
bool usePhoneAudio =
380+
!_watchService.isConnected; // Track if we're using phone audio
380381
DateTime? lastGlassesUpdate;
381382
const glassesUpdateInterval = Duration(milliseconds: 500);
382383

@@ -418,7 +419,8 @@ class AIService {
418419
);
419420
if (!success) {
420421
// Watch send failed - fall back to phone speaker
421-
debugPrint('AIService: Watch audio header failed, falling back to phone');
422+
debugPrint(
423+
'AIService: Watch audio header failed, falling back to phone');
422424
usePhoneAudio = true;
423425
await _audioPlayerService.startStreaming(
424426
sampleRate: event.sampleRate!,
@@ -442,10 +444,12 @@ class AIService {
442444
if (event.audioData != null && audioHeaderSent) {
443445
hasReceivedAudio = true;
444446
if (!usePhoneAudio && _watchService.isConnected) {
445-
final success = await _watchService.sendAudioChunk(event.audioData!);
447+
final success =
448+
await _watchService.sendAudioChunk(event.audioData!);
446449
if (!success) {
447450
// Watch send failed - switch to phone audio
448-
debugPrint('AIService: Watch audio chunk failed, switching to phone');
451+
debugPrint(
452+
'AIService: Watch audio chunk failed, switching to phone');
449453
usePhoneAudio = true;
450454
// Start phone streaming (we may have missed the header, use defaults)
451455
await _audioPlayerService.startStreaming(
@@ -740,7 +744,8 @@ class AIService {
740744
final responseBuffer = StringBuffer();
741745
bool audioHeaderSent = false;
742746
bool hasReceivedAudio = false;
743-
bool usePhoneAudio = !_watchService.isConnected; // Track if we're using phone audio
747+
bool usePhoneAudio =
748+
!_watchService.isConnected; // Track if we're using phone audio
744749
DateTime? lastGlassesUpdate;
745750
const glassesUpdateInterval = Duration(milliseconds: 500);
746751

@@ -779,7 +784,8 @@ class AIService {
779784
channels: event.channels ?? 1,
780785
);
781786
if (!success) {
782-
debugPrint('AIService: Watch audio header failed, falling back to phone');
787+
debugPrint(
788+
'AIService: Watch audio header failed, falling back to phone');
783789
usePhoneAudio = true;
784790
await _audioPlayerService.startStreaming(
785791
sampleRate: event.sampleRate!,
@@ -803,9 +809,11 @@ class AIService {
803809
if (event.audioData != null && audioHeaderSent) {
804810
hasReceivedAudio = true;
805811
if (!usePhoneAudio && _watchService.isConnected) {
806-
final success = await _watchService.sendAudioChunk(event.audioData!);
812+
final success =
813+
await _watchService.sendAudioChunk(event.audioData!);
807814
if (!success) {
808-
debugPrint('AIService: Watch audio chunk failed, switching to phone');
815+
debugPrint(
816+
'AIService: Watch audio chunk failed, switching to phone');
809817
usePhoneAudio = true;
810818
await _audioPlayerService.startStreaming(
811819
sampleRate: 24000,
@@ -915,7 +923,8 @@ class AIService {
915923
final responseBuffer = StringBuffer();
916924
bool audioHeaderSent = false;
917925
bool hasReceivedAudio = false;
918-
bool usePhoneAudio = !_watchService.isConnected; // Track if we're using phone audio
926+
bool usePhoneAudio =
927+
!_watchService.isConnected; // Track if we're using phone audio
919928
DateTime? lastGlassesUpdate;
920929
const glassesUpdateInterval = Duration(milliseconds: 500);
921930

@@ -951,7 +960,8 @@ class AIService {
951960
channels: event.channels ?? 1,
952961
);
953962
if (!success) {
954-
debugPrint('AIService: Watch audio header failed, falling back to phone');
963+
debugPrint(
964+
'AIService: Watch audio header failed, falling back to phone');
955965
usePhoneAudio = true;
956966
await _audioPlayerService.startStreaming(
957967
sampleRate: event.sampleRate!,
@@ -974,9 +984,11 @@ class AIService {
974984
if (event.audioData != null && audioHeaderSent) {
975985
hasReceivedAudio = true;
976986
if (!usePhoneAudio && _watchService.isConnected) {
977-
final success = await _watchService.sendAudioChunk(event.audioData!);
987+
final success =
988+
await _watchService.sendAudioChunk(event.audioData!);
978989
if (!success) {
979-
debugPrint('AIService: Watch audio chunk failed, switching to phone');
990+
debugPrint(
991+
'AIService: Watch audio chunk failed, switching to phone');
980992
usePhoneAudio = true;
981993
await _audioPlayerService.startStreaming(
982994
sampleRate: 24000,

0 commit comments

Comments
 (0)