-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
8698bc7
commit a7c0095
Showing
39 changed files
with
477 additions
and
638 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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createEdgeSpeechComletion } from '../src/server/createEdgeSpeechComletion'; | ||
import { EdgeSpeechPayload } 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 EdgeSpeechPayload; | ||
const res = await createEdgeSpeechComletion({ payload }); | ||
return res; | ||
}; |
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,15 +1,13 @@ | ||
import cors from '../src/server/cors'; | ||
import { getAllowOrigins } from '../src/server/getAllowOrigins'; | ||
import { handleMicrosoftSpeechRequest } from '../src/server/handleMicrosoftSpeechRequest'; | ||
import { createMicrosoftSpeechComletion } from '../src/server/createMicrosoftSpeechComletion'; | ||
import { MicrosoftSpeechPayload } 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 origin = getAllowOrigins(req); | ||
if (!origin) return new Response('Origin Not Allowed', { status: 403 }); | ||
const res = await handleMicrosoftSpeechRequest(req); | ||
return cors(req, new Response(res.body, res), { methods: ['POST'], origin }); | ||
const payload = (await req.json()) as MicrosoftSpeechPayload; | ||
const res = await createMicrosoftSpeechComletion({ payload }); | ||
return res; | ||
}; |
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,19 @@ | ||
import OpenAI from 'openai'; | ||
|
||
import { OPENAI_API_KEY, OPENAI_PROXY_URL } from '@/const/api'; | ||
|
||
import { createOpenaiAudioTranscriptionsCompletion } from '../src/server/createOpenaiAudioTranscriptionsCompletion'; | ||
import { OpenAISTTPayload } 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 OpenAISTTPayload; | ||
if (!OPENAI_API_KEY) return new Response('OPENAI_API_KEY is not set', { status: 500 }); | ||
const openai = new OpenAI({ apiKey: OPENAI_API_KEY, baseURL: OPENAI_PROXY_URL }); | ||
const res = await createOpenaiAudioTranscriptionsCompletion({ openai, payload }); | ||
return res; | ||
}; |
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,19 @@ | ||
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; | ||
if (!OPENAI_API_KEY) return new Response('OPENAI_API_KEY is not set', { status: 500 }); | ||
const openai = new OpenAI({ apiKey: OPENAI_API_KEY, baseURL: OPENAI_PROXY_URL }); | ||
const res = await createOpenaiAudioSpeechCompletion({ openai, payload }); | ||
return res; | ||
}; |
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
File renamed without changes.
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,2 +1,5 @@ | ||
export { handleAzureSpeechRequest } from './server/handleAzureSpeechRequest'; | ||
export { handleMicrosoftSpeechRequest } from './server/handleMicrosoftSpeechRequest'; | ||
export { createEdgeSpeechComletion } from '@/server/createEdgeSpeechComletion'; | ||
export { createMicrosoftSpeechComletion } from '@/server/createMicrosoftSpeechComletion'; | ||
export { createOpenaiAudioSpeechCompletion } from '@/server/createOpenaiAudioSpeechCompletion'; | ||
export { createOpenaiAudioTranscriptionsCompletion } from '@/server/createOpenaiAudioTranscriptionsCompletion'; | ||
export * from '@/server/types'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.