Skip to content

🐛 fix: Fix createEdgeSpeech hangon#55

Open
sone47 wants to merge 1 commit into
lobehub:masterfrom
sone47:master
Open

🐛 fix: Fix createEdgeSpeech hangon#55
sone47 wants to merge 1 commit into
lobehub:masterfrom
sone47:master

Conversation

@sone47
Copy link
Copy Markdown

@sone47 sone47 commented Aug 22, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

🔀 变更说明 | Description of Change

修复了当 audioData.byteLength 为空的时候,createEdgeSpeech 方法会一直挂起的问题。

📝 补充信息 | Additional Information

在某些情况下 edge tts api 不会返回语音数据,如 locale 语言设置错误,在英文语言下传入中文,这时 createEdgeSpeech 方法会一直挂起。

Summary by Sourcery

Bug Fixes:

  • Handle empty audio data in createEdgeSpeech by rejecting the promise to avoid hanging

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 22, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR updates createEdgeSpeech to explicitly reject the promise when no audio data is returned, preventing the method from hanging indefinitely.

Sequence diagram for createEdgeSpeech error handling on missing audio data

sequenceDiagram
    participant Caller
    participant createEdgeSpeech
    participant ws
    Caller->>createEdgeSpeech: Call createEdgeSpeech()
    createEdgeSpeech->>ws: Wait for 'turn.end' event
    ws-->>createEdgeSpeech: 'turn.end' received
    alt audioData.byteLength is 0
        createEdgeSpeech-->>Caller: Reject promise with error
    else audioData.byteLength > 0
        createEdgeSpeech-->>Caller: Resolve promise with Response
    end
Loading

File-Level Changes

Change Details Files
Handle empty audioData in createEdgeSpeech to avoid hanging
  • Check if audioData.byteLength is zero
  • Call reject with an error when no audio data is received
  • Return immediately after rejecting to stop further processing
src/core/EdgeSpeechTTS/createEdgeSpeech.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@lobehubbot
Copy link
Copy Markdown
Member

👍 @sone47


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants