-
-
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
c4fec41
commit e4af5b6
Showing
30 changed files
with
315 additions
and
116 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 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,15 @@ | ||
import { EdgeSpeechPayload, createEdgeSpeech } from '../src/core/EdgeSpeechTTS/createEdgeSpeech'; | ||
import cors from '../lib/cors'; | ||
import { EdgeSpeechPayload, EdgeSpeechTTS } from '../src/core'; | ||
|
||
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 createEdgeSpeech({ payload }); | ||
const res = await EdgeSpeechTTS.createRequest({ payload }); | ||
|
||
return cors(req, 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
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,25 @@ | ||
import { Icon } from '@lobehub/ui'; | ||
import { Button, Input } from 'antd'; | ||
import { Mic, StopCircle } from 'lucide-react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import { useSpeechRecognition } from '@/react'; | ||
|
||
export default () => { | ||
const { text, start, stop, isLoading, formattedTime, url } = useSpeechRecognition('zh-CN'); | ||
return ( | ||
<Flexbox gap={8}> | ||
{isLoading ? ( | ||
<Button block icon={<Icon icon={StopCircle} />} onClick={stop}> | ||
Stop {formattedTime} | ||
</Button> | ||
) : ( | ||
<Button block icon={<Icon icon={Mic} />} onClick={start} type={'primary'}> | ||
Recognition | ||
</Button> | ||
)} | ||
<Input.TextArea placeholder={'Recognition result...'} value={text} /> | ||
{url && <audio controls src={url} />} | ||
</Flexbox> | ||
); | ||
}; |
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,34 @@ | ||
import { Icon } from '@lobehub/ui'; | ||
import { Button, Input } from 'antd'; | ||
import { Volume2 } from 'lucide-react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import { AudioPlayer, useEdgeSpeech } from '@/react'; | ||
|
||
export default () => { | ||
const { setText, isGlobalLoading, start, stop, audio } = useEdgeSpeech('Edge Speech Example', { | ||
api: {}, | ||
options: { | ||
voice: 'zh-CN-YunxiaNeural', | ||
}, | ||
}); | ||
|
||
return ( | ||
<Flexbox gap={8}> | ||
{isGlobalLoading ? ( | ||
<Button block loading onClick={stop}> | ||
Generating... | ||
</Button> | ||
) : ( | ||
<Button block icon={<Icon icon={Volume2} />} onClick={start} type={'primary'}> | ||
Speak | ||
</Button> | ||
)} | ||
<Input.TextArea | ||
defaultValue={'Edge Speech Example'} | ||
onChange={(e) => setText(e.target.value)} | ||
/> | ||
<AudioPlayer audio={audio} isLoading={isGlobalLoading} onLoadingStop={stop} /> | ||
</Flexbox> | ||
); | ||
}; |
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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
import { Snippet } from '@lobehub/ui'; | ||
import { Center } from 'react-layout-kit'; | ||
import { Grid, Snippet } from '@lobehub/ui'; | ||
import { Card } from 'antd'; | ||
import { Center, Flexbox } from 'react-layout-kit'; | ||
|
||
import STT from './STT'; | ||
import TTS from './TTS'; | ||
|
||
export default () => { | ||
return ( | ||
<Center style={{ marginTop: -88 }}> | ||
<h2 style={{ fontSize: 20 }}>To install Lobe TTS, run the following command:</h2> | ||
<Snippet language={'bash'}>{'$ bun add @lobehub/tts'}</Snippet> | ||
</Center> | ||
<Flexbox gap={48} style={{ maxWidth: 960 }} width={'100%'}> | ||
<Center> | ||
<h2 style={{ fontSize: 20 }}>To install Lobe TTS, run the following command:</h2> | ||
<Snippet language={'bash'}>{'$ bun add @lobehub/tts'}</Snippet> | ||
</Center> | ||
<Grid rows={2}> | ||
<Card key={'STT'} title={'Speech Recognition'}> | ||
<STT /> | ||
</Card> | ||
<Card title={'Text to Speech'}> | ||
<TTS /> | ||
</Card> | ||
</Grid> | ||
</Flexbox> | ||
); | ||
}; |
Oops, something went wrong.