-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from freemocap/jon/add-audio
Audio transcription method
- Loading branch information
Showing
22 changed files
with
608 additions
and
105 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
IsString, | ||
IsIn, | ||
IsOptional, | ||
IsNumber, | ||
Min, | ||
Max, | ||
IsMimeType, | ||
} from 'class-validator'; | ||
import { Type } from 'class-transformer'; | ||
|
||
export class SpeechToTextDto { | ||
@IsMimeType({ | ||
each: true, | ||
message: | ||
'File must be in one of the following formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm.', | ||
}) | ||
@Type(() => Object) | ||
file: any; | ||
|
||
@IsOptional() | ||
@IsIn(['whisper-1']) | ||
model: 'whisper-1' = 'whisper-1'; | ||
|
||
@IsOptional() | ||
@IsString({ message: 'Language code must be a valid ISO-639-1 string.' }) | ||
language?: string; // ISO-639-1 format | ||
|
||
@IsOptional() | ||
@IsString({ message: 'Prompt must be a string.' }) | ||
@Max(4096, { | ||
message: 'Prompt must be less than or equal to 4096 characters.', | ||
}) | ||
prompt?: string; | ||
|
||
@IsOptional() | ||
@IsIn(['json', 'text', 'srt', 'verbose_json', 'vtt']) | ||
response_format: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt' = | ||
'verbose_json'; | ||
|
||
@IsOptional() | ||
@IsNumber() | ||
@Min(0) | ||
@Max(1) | ||
temperature: number = 0; | ||
|
||
constructor(partial: Partial<SpeechToTextDto>) { | ||
Object.assign(this, partial); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
IsString, | ||
IsIn, | ||
IsOptional, | ||
IsNumber, | ||
Min, | ||
Max, | ||
} from 'class-validator'; | ||
import { Type } from 'class-transformer'; | ||
|
||
export class TextToSpeechDto { | ||
@IsIn(['tts-1', 'tts-1-hd']) | ||
model: 'tts-1' | 'tts-1-hd'; | ||
|
||
@IsString() | ||
@IsOptional() | ||
@Type(() => String) | ||
@IsString({ message: 'Input must be a string.' }) | ||
@Max(4096, { | ||
message: 'Input must be less than or equal to 4096 characters.', | ||
}) | ||
input: string; // Text to generate audio for, max 4096 characters | ||
|
||
@IsIn(['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer']) | ||
voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer'; | ||
|
||
@IsOptional() | ||
@IsIn(['mp3', 'opus', 'aac', 'flac']) | ||
response_format?: 'mp3' | 'opus' | 'aac' | 'flac'; | ||
|
||
@IsOptional() | ||
@IsNumber() | ||
@Min(0.25) | ||
@Max(4.0) | ||
speed?: number; // Between 0.25 and 4.0, defaults to 1 | ||
|
||
constructor(partial: Partial<TextToSpeechDto>) { | ||
Object.assign(this, partial); | ||
} | ||
} |
Oops, something went wrong.