forked from open-webui/open-webui
		
	refac: audio
This commit is contained in:
		
							parent
							
								
									2a10438b4d
								
							
						
					
					
						commit
						710850e442
					
				
					 7 changed files with 133 additions and 9 deletions
				
			
		|  | @ -5,7 +5,7 @@ export const transcribeAudio = async (token: string, file: File) => { | |||
| 	data.append('file', file); | ||||
| 
 | ||||
| 	let error = null; | ||||
| 	const res = await fetch(`${AUDIO_API_BASE_URL}/transcribe`, { | ||||
| 	const res = await fetch(`${AUDIO_API_BASE_URL}/transcriptions`, { | ||||
| 		method: 'POST', | ||||
| 		headers: { | ||||
| 			Accept: 'application/json', | ||||
|  | @ -29,3 +29,34 @@ export const transcribeAudio = async (token: string, file: File) => { | |||
| 
 | ||||
| 	return res; | ||||
| }; | ||||
| 
 | ||||
| export const synthesizeOpenAISpeech = async ( | ||||
| 	token: string = '', | ||||
| 	speaker: string = 'alloy', | ||||
| 	text: string = '' | ||||
| ) => { | ||||
| 	let error = null; | ||||
| 
 | ||||
| 	const res = await fetch(`${AUDIO_API_BASE_URL}/speech`, { | ||||
| 		method: 'POST', | ||||
| 		headers: { | ||||
| 			Authorization: `Bearer ${token}`, | ||||
| 			'Content-Type': 'application/json' | ||||
| 		}, | ||||
| 		body: JSON.stringify({ | ||||
| 			model: 'tts-1', | ||||
| 			input: text, | ||||
| 			voice: speaker | ||||
| 		}) | ||||
| 	}).catch((err) => { | ||||
| 		console.log(err); | ||||
| 		error = err; | ||||
| 		return null; | ||||
| 	}); | ||||
| 
 | ||||
| 	if (error) { | ||||
| 		throw error; | ||||
| 	} | ||||
| 
 | ||||
| 	return res; | ||||
| }; | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ | |||
| 	const dispatch = createEventDispatcher(); | ||||
| 
 | ||||
| 	import { config, settings } from '$lib/stores'; | ||||
| 	import { synthesizeOpenAISpeech } from '$lib/apis/openai'; | ||||
| 	import { synthesizeOpenAISpeech } from '$lib/apis/audio'; | ||||
| 	import { imageGenerations } from '$lib/apis/images'; | ||||
| 	import { | ||||
| 		approximateToHumanReadable, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek