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

View File

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

View File

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