-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: show error message for tts model params not correct #1955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,7 @@ import EditMarkDialog from '@/views/log/component/EditMarkDialog.vue' | |
| import { datetimeFormat } from '@/utils/time' | ||
| import applicationApi from '@/api/application' | ||
| import { useRoute } from 'vue-router' | ||
| import { MsgError } from '@/utils/message' | ||
|
|
||
| const route = useRoute() | ||
| const { | ||
|
|
@@ -177,7 +178,12 @@ const playAnswerText = (text: string) => { | |
| } | ||
| applicationApi | ||
| .postTextToSpeech(id || (props.applicationId as string), { text: text }, loading) | ||
| .then((res: any) => { | ||
| .then(async (res: any) => { | ||
| if (res.type === 'application/json') { | ||
| const text = await res.text() | ||
| MsgError(text) | ||
| return | ||
| } | ||
| // 假设我们有一个 MP3 文件的字节数组 | ||
| // 创建 Blob 对象 | ||
| const blob = new Blob([res], { type: 'audio/mp3' }) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is one main issue in the provided code snippet:
Summary:The suggested changes address the memory leak risk by checking and dealing with non-json responses carefully, preventing unnecessary attempts at parsing them into text. Additionally, proper logging and clear separation between error states are maintained throughout the processing flow. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code looks generally clean and well-structured for its functionalities. However, there are a few improvements and optimizations that can be suggested:
Type Casting: Ensure type casting is used consistently throughout the code to avoid runtime errors.
Async/Await Handling: For asynchronous operations like file fetching, it's better to explicitly handle promises and avoid relying on chaining.
Comments and Documentation: Adding comments and documentation can help maintainability of the codebase.
Error Logging: Consider adding logging mechanisms to record errors effectively, especially when dealing with network requests or unexpected behavior.
Input Validation: Validate inputs before making API calls to prevent bugs caused by invalid data.
By applying these recommendations, the code will become more robust, readable, and maintainable.