Open maxdiable opened 1 year ago
Hey Max,
At a quick glance it appears to be telling us that you're trying to access the websocket through https://api.deepgram.com:0/v1/listen?encoding=linear16&sample_rate=16000&language=it-IT#
Where it should be (as you've shown in your code): wss://api.deepgram.com/v1/listen?encoding=linear16&sample_rate=16000&language=it-IT
. Note the protocol difference.
I'd be more than happy to look into it with you if you're still having this issue. Do you have Discord? If so, could you join Deepgram's official Discord server? I'm a guest on there so happy to chat there?
hi, this i my code: import 'package:flutter/material.dart'; import 'dart:async'; import 'dart:convert'; import 'package:sound_stream/sound_stream.dart'; import 'package:web_socket_channel/io.dart'; import 'package:permission_handler/permission_handler.dart';
const serverUrl = 'wss://api.deepgram.com/v1/listen?encoding=linear16&sample_rate=16000&language=it-IT'; const apiKey = 'xxxxx';
void main() { runApp(const MyApp()); }
class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key);
@override Widget build(BuildContext context) { return MaterialApp( title: 'Deepgram Live Transcription', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Deepgram Live Transcription'), ); } }
class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); final String title;
@override State createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
String myText = "To start transcribing your voice, press start.";
final RecorderStream _recorder = RecorderStream();
late StreamSubscription _recorderStatus; late StreamSubscription _audioStream;
late IOWebSocketChannel channel;
@override void initState() { super.initState();
}
@override void dispose() { _recorderStatus.cancel(); _audioStream.cancel(); channel.sink.close();
}
Future webViewMethod() async { await Permission.microphone.request(); }
Future _initStream() async {
channel = IOWebSocketChannel.connect(Uri.parse(serverUrl),
headers: {'Authorization': 'Token $apiKey'});
}
void _startRecord() async { resetText(); _initStream();
}
void _stopRecord() async { await _recorder.stop();
}
void onLayoutDone(Duration timeStamp) async { await Permission.microphone.request(); setState(() {}); }
void updateText(newText) { setState(() { myText = myText + ' ' + newText; }); }
void resetText() { setState(() { myText = ''; }); }
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Live Transcription with Deepgram'), ), body: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Row( children:[
Expanded(
flex: 3,
child: SizedBox(
width: 150,
child: Text(
myText,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
maxLines: 50,
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 15),
),
),
),
],
),
const SizedBox(height: 20),
Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.blue),
foregroundColor:
MaterialStateProperty.all(Colors.white),
),
onPressed: () {
updateText('');
} } after click on button start, flutter show this error:
Launching lib\main.dart on sdk gphone x86 64 in debug mode... Running Gradle task 'assembleDebug'... √ Built build\app\outputs\flutter-apk\app-debug.apk. Debug service listening on ws://127.0.0.1:13804/_Idlaf8Y8ZQ=/ws Syncing files to device sdk gphone x86 64... I/e.leopard_voice( 7559): Compiler allocated 4533KB to compile void android.view.ViewRootImpl.performTraversals() W/Parcel ( 7559): Expecting binder but got null! D/EGL_emulation( 7559): app_time_stats: avg=25142.68ms min=4.11ms max=50281.25ms count=2 E/flutter ( 7559): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketException: Connection to 'https://api.deepgram.com:0/v1/listen?encoding=linear16&sample_rate=16000&language=it-IT#' was not upgraded to websocket E/flutter ( 7559): #0 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1011:41) E/flutter ( 7559): #1 WebSocket.connect (dart:_http/websocket.dart:320:22) E/flutter ( 7559): #2 new IOWebSocketChannel.connect (package:web_socket_channel/io.dart:81:28) E/flutter ( 7559): #3 _MyHomePageState._initStream (package:leopard_voice/main.dart:69:34) E/flutter ( 7559): #4 _MyHomePageState._startRecord (package:leopard_voice/main.dart:95:5) E/flutter ( 7559): #5 _MyHomePageState.build. (package:leopard_voice/main.dart:168:23)
E/flutter ( 7559): #6 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1154:21)
E/flutter ( 7559): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
E/flutter ( 7559): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:654:11)
E/flutter ( 7559): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:311:5)
E/flutter ( 7559): #10 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:244:7)
E/flutter ( 7559): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:630:9)
E/flutter ( 7559): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
E/flutter ( 7559): #13 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:143:9)
E/flutter ( 7559): #14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
E/flutter ( 7559): #15 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
E/flutter ( 7559): #16 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
E/flutter ( 7559): #17 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:465:19)
E/flutter ( 7559): #18 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:445:22)
E/flutter ( 7559): #19 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:331:11)
E/flutter ( 7559): #20 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:400:7)
E/flutter ( 7559): #21 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:363:5)
E/flutter ( 7559): #22 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:320:7)
E/flutter ( 7559): #23 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:293:9)
E/flutter ( 7559): #24 _invoke1 (dart:ui/hooks.dart:158:13)
E/flutter ( 7559): #25 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:382:7)
E/flutter ( 7559): #26 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
E/flutter ( 7559):
E/flutter ( 7559): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketChannelException: WebSocketChannelException: WebSocketException: Connection to 'https://api.deepgram.com:0/v1/listen?encoding=linear16&sample_rate=16000&language=it-IT#' was not upgraded to websocket
E/flutter ( 7559): #0 new IOWebSocketChannel._withoutSocket. (package:web_socket_channel/io.dart:119:24)
E/flutter ( 7559): #1 Stream.handleError. (dart:async/stream.dart:923:16)
E/flutter ( 7559): #2 _HandleErrorStream._handleError (dart:async/stream_pipe.dart:269:17)
E/flutter ( 7559): #3 _ForwardingStreamSubscription._handleError (dart:async/stream_pipe.dart:157:13)
E/flutter ( 7559): #4 _RootZone.runBinaryGuarded (dart:async/zone.dart:1606:10)
E/flutter ( 7559): #5 _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:358:15)
E/flutter ( 7559): #6 _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:376:7)
E/flutter ( 7559): #7 _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
E/flutter ( 7559): #8 _SyncStreamControllerDispatch._sendError (dart:async/stream_controller.dart:780:19)
E/flutter ( 7559): #9 _StreamController._addError (dart:async/stream_controller.dart:658:7)
E/flutter ( 7559): #10 _RootZone.runBinaryGuarded (dart:async/zone.dart:1606:10)
E/flutter ( 7559): #11 _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:358:15)
E/flutter ( 7559): #12 _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:376:7)
E/flutter ( 7559): #13 _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
E/flutter ( 7559): #14 _SyncStreamControllerDispatch._sendError (dart:async/stream_controller.dart:780:19)
E/flutter ( 7559): #15 _StreamController._addError (dart:async/stream_controller.dart:658:7)
E/flutter ( 7559): #16 new Stream.fromFuture. (dart:async/stream.dart:245:18)
E/flutter ( 7559): #17 _RootZone.runBinary (dart:async/zone.dart:1666:54)
E/flutter ( 7559): #18 _FutureListener.handleError (dart:async/future_impl.dart:162:22)
E/flutter ( 7559): #19 Future._propagateToListeners.handleError (dart:async/future_impl.dart:796:47)
E/flutter ( 7559): #20 Future._propagateToListeners (dart:async/future_impl.dart:817:13)
E/flutter ( 7559): #21 Future._completeError (dart:async/future_impl.dart:592:5)
E/flutter ( 7559): #22 Future._asyncCompleteError. (dart:async/future_impl.dart:683:7)
E/flutter ( 7559): #23 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter ( 7559): #24 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter ( 7559):
any help ?