-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18cbd39
commit 8e2debc
Showing
25 changed files
with
245 additions
and
181 deletions.
There are no files selected for viewing
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,29 @@ | ||
import OpenAI from 'openai'; | ||
|
||
import { OpenAISTTPayload } from '@/core'; | ||
|
||
import { createOpenaiAudioTranscriptions } from '../src/server/createOpenaiAudioTranscriptions'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async (req: Request) => { | ||
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 }); | ||
|
||
const OPENAI_API_KEY = process.env.OPENAI_API_KEY; | ||
const OPENAI_PROXY_URL = process.env.OPENAI_PROXY_URL; | ||
|
||
if (!OPENAI_API_KEY) return new Response('OPENAI_API_KEY is not set', { status: 500 }); | ||
|
||
const payload = (await req.json()) as OpenAISTTPayload; | ||
|
||
const openai = new OpenAI({ apiKey: OPENAI_API_KEY, baseURL: OPENAI_PROXY_URL }); | ||
const res = await createOpenaiAudioTranscriptions({ openai, payload }); | ||
|
||
return new Response(JSON.stringify(res), { | ||
headers: { | ||
'content-type': 'application/json;charset=UTF-8', | ||
}, | ||
}); | ||
}; |
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,23 @@ | ||
import OpenAI from 'openai'; | ||
|
||
import { OpenAITTSPayload } from '@/core'; | ||
|
||
import { createOpenaiAudioSpeech } from '../src/server/createOpenaiAudioSpeech'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async (req: Request) => { | ||
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 }); | ||
const OPENAI_API_KEY = process.env.OPENAI_API_KEY; | ||
const OPENAI_PROXY_URL = process.env.OPENAI_PROXY_URL; | ||
|
||
if (!OPENAI_API_KEY) return new Response('OPENAI_API_KEY is not set', { status: 500 }); | ||
|
||
const payload = (await req.json()) as OpenAITTSPayload; | ||
|
||
const openai = new OpenAI({ apiKey: OPENAI_API_KEY, baseURL: OPENAI_PROXY_URL }); | ||
|
||
return createOpenaiAudioSpeech({ openai, payload }); | ||
}; |
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 |
---|---|---|
@@ -1,23 +1,13 @@ | ||
export { default as AudioPlayer, type AudioPlayerProps } from './AudioPlayer'; | ||
export { default as AudioVisualizer, type AudioVisualizerProps } from './AudioVisualizer'; | ||
export { type AudioPlayerHook, useAudioPlayer } from './hooks/useAudioPlayer'; | ||
export { type AudioPlayerReturn, useAudioPlayer } from './hooks/useAudioPlayer'; | ||
export { useAudioVisualizer } from './hooks/useAudioVisualizer'; | ||
export { useBlobUrl } from './hooks/useBlobUrl'; | ||
export { useStreamAudioPlayer } from './hooks/useStreamAudioPlayer'; | ||
export { useAudioRecorder } from './useAudioRecorder'; | ||
export { type EdgeSpeechOptions, useEdgeSpeech } from './useEdgeSpeech'; | ||
export { type MicrosoftSpeechOptions, useMicrosoftSpeech } from './useMicrosoftSpeech'; | ||
export { | ||
type OpenAISTTConfig, | ||
useOpenaiSTT, | ||
useOpenaiSTTWithPSR, | ||
useOpenaiSTTWithRecord, | ||
useOpenaiSTTWithSR, | ||
} from './useOpenaiSTT'; | ||
export { type OpenAITTSConfig, useOpenaiTTS } from './useOpenaiTTS'; | ||
export { usePersistedSpeechRecognition } from './useSpeechRecognition/usePersistedSpeechRecognition'; | ||
export { | ||
type SpeechRecognitionOptions, | ||
useSpeechRecognition, | ||
} from './useSpeechRecognition/useSpeechRecognition'; | ||
export { type OpenAISTTOptions, useOpenAISTT } from './useOpenAISTT'; | ||
export { type OpenAITTSOptions, useOpenAITTS } from './useOpenAITTS'; | ||
export { type SpeechRecognitionOptions, useSpeechRecognition } from './useSpeechRecognition'; | ||
export { type SpeechSynthesOptions, useSpeechSynthes } from './useSpeechSynthes'; |
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,15 @@ | ||
--- | ||
nav: Components | ||
group: STT | ||
title: useOpenAISTT | ||
--- | ||
|
||
## hooks | ||
|
||
- ENV: `OPENAI_API_KEY` `OPENAI_PROXY_URL` | ||
|
||
<code src="./demos/index.tsx" nopadding></code> | ||
|
||
## Auto Stop | ||
|
||
<code src="./demos/AutoStop.tsx" nopadding></code> |
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,12 @@ | ||
import { useOpenAISTTAutoStop } from './useOpenAISTTAutoStop'; | ||
import { useOpenAISTTInteractive } from './useOpenAISTTInteractive'; | ||
import { OpenAISTTRecorderOptions } from './useOpenAISTTRecorder'; | ||
|
||
export interface OpenAISTTOptions extends OpenAISTTRecorderOptions { | ||
autoStop?: boolean; | ||
} | ||
|
||
export const useOpenAISTT = (locale: string, { autoStop, ...rest }: OpenAISTTOptions = {}) => { | ||
const selectedHook = autoStop ? useOpenAISTTAutoStop : useOpenAISTTInteractive; | ||
return selectedHook(locale, rest); | ||
}; |
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
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
2 changes: 1 addition & 1 deletion
2
src/react/useOpenaiTTS/index.md → src/react/useOpenAITTS/index.md
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
nav: Components | ||
group: TTS | ||
title: useOpenaiTTS | ||
title: useOpenAITTS | ||
--- | ||
|
||
## hooks | ||
|
Oops, something went wrong.