This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:injectable/injectable.dart'; | |
import 'package:porcupine/porcupine.dart'; | |
import 'package:porcupine/porcupine_error.dart'; | |
import 'package:porcupine/porcupine_manager.dart'; | |
import 'package:speech_to_text/speech_recognition_result.dart'; | |
import 'package:speech_to_text/speech_to_text.dart' as stt; | |
import 'package:stacked/stacked.dart'; | |
@singleton | |
class SpeechService with ReactiveServiceMixin { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PorcupineManager porcupineManager; | |
/// Create an instance of your porcupineManager which will listen for the given wake words | |
/// Must call start on the manager to actually start listening | |
void createPorcupineManager() async { | |
try{ | |
porcupineManager = await PorcupineManager.fromKeywords( | |
Porcupine.BUILT_IN_KEYWORDS, | |
wakeWordCallback); | |
} on PvError catch (err) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:desk_monkey/services/services.dart'; | |
import 'package:stacked/stacked.dart'; | |
class SingleCommandViewModel extends BaseViewModel{ | |
String recognizedWords = ''; | |
void initialize(){ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:stacked/stacked.dart'; | |
import 'single_command_view_model.dart'; | |
class SingleCommandView extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ViewModelBuilder<SingleCommandViewModel>.reactive( | |
viewModelBuilder: () => SingleCommandViewModel(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:injectable/injectable.dart'; | |
import 'package:speech_to_text/speech_recognition_result.dart'; | |
import 'package:speech_to_text/speech_to_text.dart' as stt; | |
@singleton | |
class SpeechService{ | |
bool speechAvailable = false; | |
stt.SpeechToText speech = stt.SpeechToText(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uint8List pic; | |
Future<void> readPic() async { | |
AtKey atKey = AtKey(); | |
atKey.key = 'pic'; | |
// Get keys shared by the other sign | |
if (!mine) { | |
atKey.sharedBy = AtConstants().atMap[atProtocolService.currentAtSign]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> sendImage() async { | |
AtKey atKey = AtKey(); | |
atKey.key = 'pic'; | |
/// Share with the other sign | |
if (shareWith) { | |
atKey.sharedWith = AtConstants().atMap[atProtocolService.currentAtSign]; | |
} | |
String encodedImage = Base2e15.encode( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@injectable | |
class MediaService { | |
final picker = ImagePicker(); | |
/// Select an image from the user's device | |
Future<File> selectImage({ImageSource source = ImageSource.gallery}) async { | |
final pickedFile = await picker.getImage(source: source); | |
if(pickedFile!= null) { | |
return File(pickedFile.path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> incrementCounter(String key) async { | |
AtKey atKey = AtKey(); | |
atKey.key = key; | |
/// Share with the other sign | |
if(shareWith) { | |
atKey.sharedWith = AtConstants().atMap[atProtocolService.currentAtSign]; | |
} | |
counter++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> initialize() async { | |
String privateKey = await atProtocolService.getPrivateKey(atProtocolService.currentAtSign); | |
try { | |
atProtocolService.atClientImpl.startMonitor(privateKey, printResult); | |
} on ConnectionInvalidException catch (e){ | |
print('connection error: '+ e.toString()); | |
} | |
} | |
Future<void> printResult(String val) async { |