File tree Expand file tree Collapse file tree
adminforth/types/adapters Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ export type SpeechToTextInput = {
2+ buffer : Buffer ;
3+ filename : string ;
4+ mimeType : string ;
5+ language ?: string ;
6+ prompt ?: string ;
7+ } ;
8+
9+ export type SpeechToTextResult = {
10+ text : string ;
11+ language ?: string ;
12+ raw ?: unknown ;
13+ } ;
14+
15+ export interface SpeechToTextAdapter {
16+ name : string ;
17+
18+ validate ( ) : void ;
19+
20+ transcribe ( input : SpeechToTextInput ) : Promise < SpeechToTextResult > ;
21+ }
22+
23+ export type TtsAudioFormat =
24+ | "mp3"
25+ | "opus"
26+ | "aac"
27+ | "flac"
28+ | "wav"
29+ | "pcm" ;
30+
31+ export type TextToSpeechInput < Voice extends string = string > = {
32+ text : string ;
33+ voice ?: Voice ;
34+ format ?: TtsAudioFormat ;
35+ speed ?: number ;
36+ instructions ?: string ;
37+ stream ?: false ;
38+ } ;
39+
40+ export type TextToSpeechResult = {
41+ audio : Buffer ;
42+ mimeType : string ;
43+ format : TtsAudioFormat ;
44+ raw ?: unknown ;
45+ } ;
46+
47+ export type TtsStreamFormat = "audio" | "sse" ;
48+
49+ export type TextToSpeechStreamInput < Voice extends string = string > =
50+ Omit < TextToSpeechInput < Voice > , "stream" > & {
51+ stream : true ;
52+ streamFormat ?: TtsStreamFormat ;
53+ } ;
54+
55+ export type TextToSpeechStreamResult = {
56+ audioStream : ReadableStream < Uint8Array > ;
57+ mimeType : string ;
58+ format : TtsAudioFormat ;
59+ streamFormat : TtsStreamFormat ;
60+ raw ?: unknown ;
61+ } ;
62+
63+ export interface TextToSpeechAdapter < Voice extends string = string > {
64+ name : string ;
65+
66+ validate ( ) : void ;
67+
68+ synthesize ( input : TextToSpeechStreamInput < Voice > ) : Promise < TextToSpeechStreamResult > ;
69+ synthesize ( input : TextToSpeechInput < Voice > ) : Promise < TextToSpeechResult > ;
70+ }
71+
72+ export type AudioAdapter < Voice extends string = string > =
73+ SpeechToTextAdapter & TextToSpeechAdapter < Voice > ;
Original file line number Diff line number Diff line change @@ -15,3 +15,13 @@ export type { ImageVisionAdapter } from './ImageVisionAdapter.js';
1515export type { OAuth2Adapter } from './OAuth2Adapter.js' ;
1616export type { StorageAdapter } from './StorageAdapter.js' ;
1717export type { CaptchaAdapter } from './CaptchaAdapter.js' ;
18+ export type {
19+ AudioAdapter ,
20+ SpeechToTextAdapter ,
21+ SpeechToTextInput ,
22+ SpeechToTextResult ,
23+ TextToSpeechAdapter ,
24+ TextToSpeechInput ,
25+ TextToSpeechResult ,
26+ TtsAudioFormat ,
27+ } from './AudioAdapter.js' ;
You can’t perform that action at this time.
0 commit comments