-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Add new section to README.md and create new API file
- Add a new section to the README.md file - Create a new file in the API directory - Implement functions and interfaces for fetching and processing speech data from various APIs - Modify functions related to speech synthesis - Update the utterance object based on provided options - Handle dependencies for the useEffect hook - Update the voiceList state when the voices change These changes introduce new features and improve the functionality of the code for speech data processing and synthesis.
- Loading branch information
1 parent
58770b5
commit 630b586
Showing
19 changed files
with
161 additions
and
183 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,31 @@ | ||
import cors from '../lib/cors'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
const API = | ||
'https://southeastasia.api.speech.microsoft.com/accfreetrial/texttospeech/acc/v3.0-beta1/vcg/speak'; | ||
|
||
const MICROSOFT_SPEECH_ALLOW_ORIGINS = | ||
process.env?.MICROSOFT_SPEECH_ALLOW_ORIGINS?.split(',') || undefined; | ||
|
||
export default async (req: Request) => { | ||
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 }); | ||
|
||
let origin = '*'; | ||
|
||
if (MICROSOFT_SPEECH_ALLOW_ORIGINS) { | ||
const reqOrigin = req.headers.get('origin'); | ||
if (reqOrigin && MICROSOFT_SPEECH_ALLOW_ORIGINS.includes(reqOrigin)) { | ||
origin = reqOrigin; | ||
} else { | ||
return new Response('Origin Not Allowed', { status: 403 }); | ||
} | ||
} | ||
|
||
const res = await fetch(API, { body: req.body, headers: req.headers, method: 'POST' }); | ||
const newResponse = new Response(res.body, res); | ||
|
||
return cors(req, newResponse, { methods: ['POST'], origin }); | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import urlJoin from 'url-join'; | ||
|
||
export const MICROSOFT_SPEECH_PROXY_URL = process.env.MICROSOFT_SPEECH_PROXY_URL || ''; | ||
export const MICROSOFT_SPEECH_PROXY_URL = | ||
process.env.MICROSOFT_SPEECH_PROXY_URL || '/api/microsoft-speech'; | ||
export const AZURE_SPEECH_KEY = process.env.AZURE_SPEECH_KEY || ''; | ||
export const AZURE_SPEECH_REGION = process.env.AZURE_SPEECH_REGION || ''; | ||
export const OPENAI_API_KEY = process.env.OPENAI_API_KEY || ''; | ||
export const OPENAI_PROXY_URL = process.env.OPENAI_PROXY_URL || 'https://api.openai.com/v1'; | ||
export const OPENAI_TTS_URL = (api?: string) => urlJoin(api || OPENAI_PROXY_URL, 'audio/speech'); | ||
export const OPENAI_STT_URL = (api: string) => | ||
urlJoin(api || OPENAI_PROXY_URL, 'audio/transcriptions'); | ||
export const EDDGE_PROXY_URL = | ||
process.env.EDDGE_PROXY_URL || | ||
'wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1'; | ||
export const EDDGE_API_TOKEN = process.env.EDDGE_API_TOKEN || '6A5AA1D4EAFF4E9FB37E23D68491D6F4'; |
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
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
Oops, something went wrong.