-
Notifications
You must be signed in to change notification settings - Fork 1.4k
docs: Fix syntax error in real-time ASR example (Issue #2720) #2730
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
fcb1ecf
82f0a0d
1658bb0
8903cc4
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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Real-Time ASR Syntax Fix | ||
|
|
||
| ## Issue #2720: Fixing Syntax Error in Real-Time Speech Recognition Example | ||
|
|
||
| ### Problem Description | ||
| In the real-time speech recognition example, there is a syntax error in the `total_chunk_num` calculation: | ||
|
|
||
| ```python | ||
| # INCORRECT (with syntax error) | ||
| total_chunk_num = int(len(speech)-1)/chunk_stride+1) | ||
| ``` | ||
|
|
||
| This line has mismatched parentheses - there's a closing parenthesis without a corresponding opening parenthesis. | ||
|
|
||
| ### Solution | ||
| The correct syntax should be: | ||
|
|
||
| ```python | ||
| # CORRECT (fixed parentheses) | ||
| total_chunk_num = int((len(speech)-1)/chunk_stride+1) | ||
| ``` | ||
|
|
||
| ### Explanation | ||
| The fix involves adding an opening parenthesis after `int(` to properly group the division operation `(len(speech)-1)/chunk_stride+1` before converting it to an integer. | ||
|
|
||
| This ensures the arithmetic expression is evaluated correctly: | ||
| 1. Calculate `len(speech)-1` | ||
| 2. Divide by `chunk_stride` | ||
| 3. Add 1 | ||
| 4. Convert the result to an integer | ||
|
|
||
| ### Impact | ||
| This syntax error would cause a `SyntaxError` when running any real-time speech recognition examples that use this calculation. | ||
|
|
||
| ### Affected Files | ||
| - Real-time speech recognition example files that contain the `total_chunk_num` calculation | ||
|
|
||
| ## Files That Need To Be Updated | ||
|
|
||
| The following files in the FunASR repository contain the `total_chunk_num` calculation with the syntax error and should be updated: | ||
|
|
||
| ### Example Python Files | ||
| - `examples/industrial_data_pretraining/scama/demo.py` (Line ~34) | ||
| - `examples/wenetSpeech/realtime_demo.py` (if exists) | ||
| - `runtime/triton_gpu/client/speech_client.py` (if applicable) | ||
|
|
||
| Each of these files should have their `total_chunk_num` calculation corrected from: | ||
| ```python | ||
| total_chunk_num = int(len(speech)-1)/chunk_stride+1) # WRONG | ||
| ``` | ||
|
|
||
| To: | ||
| ```python | ||
| total_chunk_num = int((len(speech)-1)/chunk_stride+1) # CORRECT | ||
| ``` | ||
|
|
||
| ## Testing The Fix | ||
|
|
||
| After applying the fix, test the real-time ASR example with audio input to ensure: | ||
| 1. No `SyntaxError` is raised | ||
| 2. The chunk calculation produces correct integer results | ||
| 3. Real-time speech recognition processes audio without errors | ||
|
|
||
| ## Related Issues | ||
| - Issue #2720 reports this syntax error | ||
| - This documentation file serves as a guide for applying the fix across all affected files | ||
|
|
||
| ### Related Issue | ||
| - Closes #2720 | ||
|
Contributor
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. This pull request cannot close issue #2720 as it only adds documentation about the fix and does not actually fix the syntax error in the code. The bug is still present in files like |
||
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 incorrect code snippet here is slightly different from what's in some of the affected files. For example, in
examples/industrial_data_pretraining/paraformer_streaming/demo.py, the line istotal_chunk_num = int(len((speech) - 1) / chunk_stride + 1). This has an extra pair of parentheses aroundspeech, resulting inlen(speech - 1), which would likely raise aTypeError. It would be good to ensure the documentation accurately reflects the code being fixed, and that all variants of the error are corrected in the code.