-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Showing
7 changed files
with
29 additions
and
35 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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { createEdgeSpeechComletion } from '../src/server/createEdgeSpeechComletion'; | ||
import { EdgeSpeechPayload } from '../src/server/types'; | ||
import { EdgeSpeechPayload, createEdgeSpeechComletion } from '@lobehub/tts'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async (req: Request) => { | ||
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 }); | ||
|
||
const payload = (await req.json()) as EdgeSpeechPayload; | ||
const res = await createEdgeSpeechComletion({ payload }); | ||
return res; | ||
|
||
return createEdgeSpeechComletion({ 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,19 +1,19 @@ | ||
import { OpenAITTSPayload, createOpenaiAudioSpeechCompletion } from '@lobehub/tts'; | ||
import OpenAI from 'openai'; | ||
|
||
import { OPENAI_API_KEY, OPENAI_PROXY_URL } from '@/const/api'; | ||
|
||
import { createOpenaiAudioSpeechCompletion } from '../src/server/createOpenaiAudioSpeechCompletion'; | ||
import { OpenAITTSPayload } from '../src/server/types'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async (req: Request) => { | ||
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 }); | ||
const payload = (await req.json()) as OpenAITTSPayload; | ||
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 }); | ||
const res = await createOpenaiAudioSpeechCompletion({ openai, payload }); | ||
return res; | ||
|
||
return createOpenaiAudioSpeechCompletion({ 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