perf: speech check (#3351)

* perf: speech check

* perf: version
This commit is contained in:
Archer
2024-12-09 21:27:07 +08:00
committed by GitHub
parent 15dc7b220e
commit 1b8b11239c
4 changed files with 16 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "app", "name": "app",
"version": "4.8.14", "version": "4.8.15",
"private": false, "private": false,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -8,16 +8,17 @@ import { authChatCrud } from '@/service/support/permission/auth/chat';
import { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat'; import { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat';
import { NextAPI } from '@/service/middleware/entry'; import { NextAPI } from '@/service/middleware/entry';
import { aiTranscriptions } from '@fastgpt/service/core/ai/audio/transcriptions'; import { aiTranscriptions } from '@fastgpt/service/core/ai/audio/transcriptions';
import { useReqFrequencyLimit } from '@fastgpt/service/common/middle/reqFrequencyLimit';
const upload = getUploadModel({ const upload = getUploadModel({
maxSize: 20 maxSize: 5
}); });
async function handler(req: NextApiRequest, res: NextApiResponse<any>) { async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
let filePaths: string[] = []; let filePaths: string[] = [];
try { try {
const { let {
file, file,
data: { appId, duration, shareId, outLinkUid, teamId: spaceTeamId, teamToken } data: { appId, duration, shareId, outLinkUid, teamId: spaceTeamId, teamToken }
} = await upload.doUpload< } = await upload.doUpload<
@@ -42,9 +43,17 @@ async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
if (!file) { if (!file) {
throw new Error('file not found'); throw new Error('file not found');
} }
if (duration === undefined) {
throw new Error('duration not found');
}
duration = duration < 1 ? 1 : duration;
// auth role // auth role
const { teamId, tmbId } = await authChatCrud({ req, authToken: true, ...req.body }); const { teamId, tmbId } = await authChatCrud({
req,
authToken: true,
...req.body
});
// auth app // auth app
// const app = await MongoApp.findById(appId, 'modules').lean(); // const app = await MongoApp.findById(appId, 'modules').lean();
@@ -80,7 +89,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
removeFilesByPaths(filePaths); removeFilesByPaths(filePaths);
} }
export default NextAPI(handler); export default NextAPI(useReqFrequencyLimit(1, 2), handler);
export const config = { export const config = {
api: { api: {

View File

@@ -141,7 +141,7 @@ export const AiPointsTable = () => {
<Box flex={'1 0 0'}> <Box flex={'1 0 0'}>
{whisperModel?.charsPointsPrice + {whisperModel?.charsPointsPrice +
t('common:support.wallet.subscription.point') + t('common:support.wallet.subscription.point') +
' / 1000' + ' / 60' +
t('common:unit.minute')} t('common:unit.minute')}
</Box> </Box>
</Flex> </Flex>

View File

@@ -103,7 +103,7 @@ export const useAudioPlay = (
const cancelAudio = useCallback(() => { const cancelAudio = useCallback(() => {
try { try {
window.speechSynthesis?.cancel(); window.speechSynthesis?.cancel();
audioController.current.abort(''); !audioController.current.signal.aborted && audioController.current.abort();
} catch (error) {} } catch (error) {}
if (audioRef.current) { if (audioRef.current) {
audioRef.current.pause(); audioRef.current.pause();