-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
90 changed files
with
1,094 additions
and
828 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,14 @@ | ||
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; | ||
|
||
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
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; | ||
|
||
return createMicrosoftSpeechComletion({ 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import OpenAI from 'openai'; | ||
|
||
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 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 createOpenaiAudioTranscriptionsCompletion({ openai, payload }); | ||
|
||
return new Response(JSON.stringify(res), { | ||
headers: { | ||
'content-type': 'application/json;charset=UTF-8', | ||
}, | ||
}); | ||
}; |
Oops, something went wrong.