-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fix invalid characters in speech to text result #1857
Conversation
No Taskcluster jobs started for this pull requestThe `allowPullRequests` configuration for this repository (in `.taskcluster.yml` on the
default branch) does not allow starting tasks for this pull request. |
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.
Thanks for the PR! I have a comment of comments (inline).
while (Marshal.ReadByte(res, len) != 0) ++len; | ||
byte[] buffer = new byte[len]; | ||
Marshal.Copy(res, buffer, 0, buffer.Length); | ||
return Encoding.UTF8.GetString(buffer); |
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.
Can these lines instead just be return Marshall.PtrToStringUTF8(res)
?
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.
Seems no, there's no direct Marshal for UTF-8.
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.
Ah, looks like it was added in a version of .NET that's more recent than the one we use: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.ptrtostringutf8
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.
Current client is not .NET Core so we'll have to go with this unless we change framework.
examples/net_framework/CSharpExamples/DeepSpeechClient/DeepSpeech.cs
Outdated
Show resolved
Hide resolved
No Taskcluster jobs started for this pull requestThe `allowPullRequests` configuration for this repository (in `.taskcluster.yml` on the
default branch) does not allow starting tasks for this pull request. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Default string in .NET uses UTF-16 causing invalid characters to appear as mentioned in here. This pull fixes the issue by returning the result as UTF-8.