Skip to content

Instantly share code, notes, and snippets.

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 {
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) {
import 'package:desk_monkey/services/services.dart';
import 'package:stacked/stacked.dart';
class SingleCommandViewModel extends BaseViewModel{
String recognizedWords = '';
void initialize(){
}
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(),
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();
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];
}
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(
@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);
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++;
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 {