/audio-to-text API return entry only #13962

Closed
opened 2026-02-21 19:14:48 -05:00 by yindo · 4 comments
Owner

Originally created by @ooxx87 on GitHub (May 16, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.4.0

Cloud or Self Hosted

Cloud

Steps to reproduce

recordRef.current.onstop = async () => {
const fileType = 'audio/mp3'
const blob = new Blob(audioChunks.current, { type: fileType });
const mp3File = new File([blob], 'temp.mp3', { type: fileType })

    Modal.info({
      content: (
        <>
          <SyncOutlined spin />
          <span>正在语音识别,请稍后...</span>
        </>
      ),
      footer: null,
      centered: true,
      getContainer: false,
    })

    try {
      const {text} = await DifyApi.chatAudioToText(getUseAgentCode(), { file: mp3File, type: fileType }) || {}

      if ((text ?? '') == '') {
        message.info('没有识别到语音内容')
      }

      setContent((old) => {
        return old + text
      })
    } catch (error) {
      
    } finally {
      audioChunks.current = [];
      stream.getTracks().forEach(track => track.stop());
      Modal.destroyAll();
    }

  }

Image

Image

✔️ Expected Behavior

I have compared the code with the parameters of the initiating voice of the agent set up on the official website. When the parameter contents are the same, the api cannot return correctly.

Request the official to spare some time to fix it.

Actual Behavior

No response

Originally created by @ooxx87 on GitHub (May 16, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.4.0 ### Cloud or Self Hosted Cloud ### Steps to reproduce recordRef.current.onstop = async () => { const fileType = 'audio/mp3' const blob = new Blob(audioChunks.current, { type: fileType }); const mp3File = new File([blob], 'temp.mp3', { type: fileType }) Modal.info({ content: ( <> <SyncOutlined spin /> <span>正在语音识别,请稍后...</span> </> ), footer: null, centered: true, getContainer: false, }) try { const {text} = await DifyApi.chatAudioToText(getUseAgentCode(), { file: mp3File, type: fileType }) || {} if ((text ?? '') == '') { message.info('没有识别到语音内容') } setContent((old) => { return old + text }) } catch (error) { } finally { audioChunks.current = []; stream.getTracks().forEach(track => track.stop()); Modal.destroyAll(); } } ![Image](https://github.com/user-attachments/assets/bc3ff264-038a-49e1-947f-ce1e1580c562) ![Image](https://github.com/user-attachments/assets/cc4ffc44-149f-4a57-ba73-9dfd20bca1e1) ### ✔️ Expected Behavior I have compared the code with the parameters of the initiating voice of the agent set up on the official website. When the parameter contents are the same, the api cannot return correctly. Request the official to spare some time to fix it. ### ❌ Actual Behavior _No response_
yindo added the 🐞 bugstt & ttscloud labels 2026-02-21 19:14:48 -05:00
yindo closed this issue 2026-02-21 19:14:48 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (May 16, 2025):

Hello @ooxx87! I'm Dosu, your friendly bot here to help you solve bugs, answer questions, and assist you in becoming a contributor. While you wait for a human maintainer, feel free to let me know if there's anything specific you'd like to discuss!

The issue you're experiencing, where the /audio-to-text API returns an empty string in the 'text' field, could be due to several reasons. Here are some potential causes and solutions:

  1. Audio Quality: Ensure that the audio file is clear and free of background noise. Poor audio quality can lead to unsuccessful transcription.

  2. File Format and Size: Verify that the audio file is in a supported format (mp3, mp4, mpeg, mpga, m4a, wav, webm) and does not exceed the 15MB size limit [1].

  3. Content-Type: Make sure the Content-Type is correctly set when uploading the file. For an MP3 file, it should be audio/mp3 [2].

  4. API Configuration: Double-check that the API is correctly configured and that all required parameters are being passed, including a unique user identifier [1].

  5. Error Handling: Implement error handling to catch any specific errors returned by the API, such as UnsupportedAudioTypeError or ProviderNotSupportSpeechToTextError [3].

If these steps do not resolve the issue, it might be helpful to review the server logs for any additional error messages or to test with different audio files to isolate the problem.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (May 16, 2025): <!-- Greeting --> Hello @ooxx87! I'm [Dosu](https://dosu.dev), your friendly bot here to help you solve bugs, answer questions, and assist you in becoming a contributor. While you wait for a human maintainer, feel free to let me know if there's anything specific you'd like to discuss! <!-- Answer --> The issue you're experiencing, where the `/audio-to-text` API returns an empty string in the 'text' field, could be due to several reasons. Here are some potential causes and solutions: 1. **Audio Quality**: Ensure that the audio file is clear and free of background noise. Poor audio quality can lead to unsuccessful transcription. 2. **File Format and Size**: Verify that the audio file is in a supported format (`mp3`, `mp4`, `mpeg`, `mpga`, `m4a`, `wav`, `webm`) and does not exceed the 15MB size limit <sup>[[1]](https://github.com/crazywoola/dify-docs-mintlify/blob/main/api_access/chat.zh.mdx)</sup>. 3. **Content-Type**: Make sure the `Content-Type` is correctly set when uploading the file. For an MP3 file, it should be `audio/mp3` <sup>[[2]](https://github.com/langgenius/dify/issues/18791)</sup>. 4. **API Configuration**: Double-check that the API is correctly configured and that all required parameters are being passed, including a unique `user` identifier <sup>[[1]](https://github.com/crazywoola/dify-docs-mintlify/blob/main/api_access/chat.zh.mdx)</sup>. 5. **Error Handling**: Implement error handling to catch any specific errors returned by the API, such as `UnsupportedAudioTypeError` or `ProviderNotSupportSpeechToTextError` <sup>[[3]](https://github.com/langgenius/dify/blob/main/api/controllers/console/explore/audio.py)</sup>. If these steps do not resolve the issue, it might be helpful to review the server logs for any additional error messages or to test with different audio files to isolate the problem. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8b22688c-71bb-4755-9734-63a6668f6f31?feedback_type=other)</sup>
Author
Owner

@Killua67 commented on GitHub (May 26, 2025):

I have the same issue

@Killua67 commented on GitHub (May 26, 2025): I have the same issue
Author
Owner

@charli117 commented on GitHub (May 27, 2025):

Which one is used as the default ASR model

@charli117 commented on GitHub (May 27, 2025): Which one is used as the default ASR model
Author
Owner

@666Aizen commented on GitHub (Nov 25, 2025):

我也遇到了返回为空的问题,解决了吗

@666Aizen commented on GitHub (Nov 25, 2025): 我也遇到了返回为空的问题,解决了吗
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13962