Skip to content

Commit

Permalink
perf: speech check (#3351)
Browse files Browse the repository at this point in the history
* perf: speech check

* perf: version
  • Loading branch information
c121914yu authored Dec 9, 2024
1 parent 15dc7b2 commit 1b8b112
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion projects/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "4.8.14",
"version": "4.8.15",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
17 changes: 13 additions & 4 deletions projects/app/src/pages/api/v1/audio/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -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();
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/price/components/Points.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/web/common/utils/voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1b8b112

Please sign in to comment.