File tree Expand file tree Collapse file tree
examples/disabled_deno-prerecorded Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { require } from "https://deno.land/x/require/mod.ts" ;
2+ import { dirname } from "https://deno.land/std/path/mod.ts" ;
3+ import { fileURLToPath } from "https://deno.land/std@0.177.0/node/url.ts" ;
4+
5+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
6+
7+ const { createClient } = require ( "../../dist/module/index.js" ) ;
8+
9+ const transcribeUrl = async ( ) => {
10+ const deepgram = createClient ( Deno . env . get ( "DEEPGRAM_API_KEY" ) ) ;
11+
12+ console . log ( "Transcribing URL" , "https://dpgr.am/spacewalk.wav" ) ;
13+ const { result, error } = await deepgram . listen . prerecorded . transcribeUrl (
14+ {
15+ url : "https://dpgr.am/spacewalk.wav" ,
16+ } ,
17+ {
18+ model : "nova-2" ,
19+ }
20+ ) ;
21+
22+ if ( error ) console . error ( error ) ;
23+ if ( ! error ) console . dir ( result , { depth : 1 } ) ;
24+ } ;
25+
26+ const transcribeFile = async ( ) => {
27+ const deepgram = createClient ( Deno . env . get ( "DEEPGRAM_API_KEY" ) ) ;
28+
29+ const filePath = path . join ( __dirname , "../spacewalk.wav" ) ;
30+ console . log ( filePath ) ;
31+ const file = await Deno . readFile ( filePath ) ;
32+
33+ console . log ( "Transcribing file" , file ) ;
34+ const { result, error } = await deepgram . listen . prerecorded . transcribeFile ( file , {
35+ model : "nova-2" ,
36+ } ) ;
37+
38+ if ( error ) console . error ( error ) ;
39+ if ( ! error ) console . dir ( result , { depth : 1 } ) ;
40+ } ;
41+
42+ transcribeUrl ( ) ;
43+ transcribeFile ( ) ;
Original file line number Diff line number Diff line change @@ -16,8 +16,9 @@ export function stripTrailingSlash(url: string): string {
1616 return url . replace ( / \/ $ / , "" ) ;
1717}
1818
19- export const isBrowser = ( ) => typeof window !== "undefined" ;
20- export const isServer = ( ) => typeof process !== "undefined" ;
19+ export function isBrowser ( ) {
20+ return typeof window !== "undefined" && typeof window . document !== "undefined" ;
21+ }
2122
2223export function applyDefaults < O , S > ( options : Partial < O > = { } , subordinate : Partial < S > = { } ) : S {
2324 return merge ( subordinate , options ) ;
You can’t perform that action at this time.
0 commit comments