Skip to content

Commit

Permalink
minor: bump version changes for 3.2 sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
saitharunsai committed Sep 21, 2024
1 parent a9cf593 commit 7e64313
Show file tree
Hide file tree
Showing 3 changed files with 3,846 additions and 12 deletions.
7 changes: 3 additions & 4 deletions app/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useEffect, useRef, useState } from "react";
import {
LiveConnectionState,
SOCKET_STATES,
LiveTranscriptionEvent,
LiveTranscriptionEvents,
useDeepgram,
Expand Down Expand Up @@ -58,7 +58,6 @@ const App: () => JSX.Element = () => {
const { is_final: isFinal, speech_final: speechFinal } = data;
let thisCaption = data.channel.alternatives[0].transcript;

console.log("thisCaption", thisCaption);
if (thisCaption !== "") {
console.log('thisCaption !== ""', thisCaption);
setCaption(thisCaption);
Expand All @@ -73,7 +72,7 @@ const App: () => JSX.Element = () => {
}
};

if (connectionState === LiveConnectionState.OPEN) {
if (connectionState === SOCKET_STATES.open) {
connection.addListener(LiveTranscriptionEvents.Transcript, onTranscript);
microphone.addEventListener(MicrophoneEvents.DataAvailable, onData);

Expand All @@ -94,7 +93,7 @@ const App: () => JSX.Element = () => {

if (
microphoneState !== MicrophoneState.Open &&
connectionState === LiveConnectionState.OPEN
connectionState === SOCKET_STATES.open
) {
connection.keepAlive();

Expand Down
16 changes: 8 additions & 8 deletions app/context/DeepgramContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {
createClient,
LiveClient,
LiveConnectionState,
SOCKET_STATES,
LiveTranscriptionEvents,
type LiveSchema,
type LiveTranscriptionEvent,
Expand All @@ -21,7 +21,7 @@ interface DeepgramContextType {
connection: LiveClient | null;
connectToDeepgram: (options: LiveSchema, endpoint?: string) => Promise<void>;
disconnectFromDeepgram: () => void;
connectionState: LiveConnectionState;
connectionState: SOCKET_STATES;
}

const DeepgramContext = createContext<DeepgramContextType | undefined>(
Expand All @@ -42,8 +42,8 @@ const DeepgramContextProvider: FunctionComponent<
DeepgramContextProviderProps
> = ({ children }) => {
const [connection, setConnection] = useState<LiveClient | null>(null);
const [connectionState, setConnectionState] = useState<LiveConnectionState>(
LiveConnectionState.CLOSED
const [connectionState, setConnectionState] = useState<SOCKET_STATES>(
SOCKET_STATES.closed
);

/**
Expand All @@ -60,19 +60,19 @@ const DeepgramContextProvider: FunctionComponent<
const conn = deepgram.listen.live(options, endpoint);

conn.addListener(LiveTranscriptionEvents.Open, () => {
setConnectionState(LiveConnectionState.OPEN);
setConnectionState(SOCKET_STATES.open);
});

conn.addListener(LiveTranscriptionEvents.Close, () => {
setConnectionState(LiveConnectionState.CLOSED);
setConnectionState(SOCKET_STATES.closed);
});

setConnection(conn);
};

const disconnectFromDeepgram = async () => {
if (connection) {
connection.finish();
connection.requestClose();
setConnection(null);
}
};
Expand Down Expand Up @@ -104,7 +104,7 @@ function useDeepgram(): DeepgramContextType {
export {
DeepgramContextProvider,
useDeepgram,
LiveConnectionState,
SOCKET_STATES,
LiveTranscriptionEvents,
type LiveTranscriptionEvent,
};
Loading

0 comments on commit 7e64313

Please sign in to comment.