feat: Explicitly set and default TTS response format to MP3.
This commit is contained in:
parent
f5cd3b262a
commit
6e442e8dba
2 changed files with 4 additions and 1 deletions
|
|
@ -252,12 +252,14 @@ export async function POST(req: NextRequest) {
|
||||||
: voice
|
: voice
|
||||||
) as SpeechCreateParams['voice'];
|
) as SpeechCreateParams['voice'];
|
||||||
|
|
||||||
|
const resolvedFormat = format || 'mp3';
|
||||||
|
|
||||||
const createParams: ExtendedSpeechParams = {
|
const createParams: ExtendedSpeechParams = {
|
||||||
model: model,
|
model: model,
|
||||||
voice: normalizedVoice,
|
voice: normalizedVoice,
|
||||||
input: text,
|
input: text,
|
||||||
speed: speed,
|
speed: speed,
|
||||||
response_format: format,
|
response_format: resolvedFormat,
|
||||||
};
|
};
|
||||||
// Only add instructions if model is gpt-4o-mini-tts and instructions are provided
|
// Only add instructions if model is gpt-4o-mini-tts and instructions are provided
|
||||||
if ((model as string) === 'gpt-4o-mini-tts' && instructions) {
|
if ((model as string) === 'gpt-4o-mini-tts' && instructions) {
|
||||||
|
|
|
||||||
|
|
@ -1036,6 +1036,7 @@ export function TTSProvider({ children }: { children: ReactNode }): ReactElement
|
||||||
text: sentence,
|
text: sentence,
|
||||||
voice,
|
voice,
|
||||||
speed,
|
speed,
|
||||||
|
format: 'mp3',
|
||||||
model: ttsModel,
|
model: ttsModel,
|
||||||
instructions: ttsModel === 'gpt-4o-mini-tts' ? ttsInstructions : undefined,
|
instructions: ttsModel === 'gpt-4o-mini-tts' ? ttsInstructions : undefined,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue