将音频转换为文本

发布于 2024-09-28 02:39:38 字数 91 浏览 9 评论 0原文

我只是想知道 Java 或 C# 中是否有任何内置库或外部库允许我获取音频文件并解析它并从中提取文本。

我需要提出申请才能这样做,但我不知道从哪里开始。

I just want to know if there is any build in libraries or external libraries in Java or C# that allow me to take an audio file and parse it and extract the text from it.

I need to make an application to do so, but I don't know from where I can start.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

我们的影子 2024-10-05 02:39:38

这是使用 C# 和 System.Speech 的完整示例

代码可分为 2 个主要部分:

配置 SpeechRecognitionEngine 对象(及其所需元素)
处理 SpeechRecognized 和 SpeechHypothesized 事件。

第 1 步:配置 SpeechRecognitionEngine

_speechRecognitionEngine = new SpeechRecognitionEngine();
_speechRecognitionEngine.SetInputToDefaultAudioDevice();
_dictationGrammar = new DictationGrammar();
_speechRecognitionEngine.LoadGrammar(_dictationGrammar);
_speechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);

此时,您的对象已准备好开始从麦克风转录音频。不过,您需要处理一些事件,才能真正访问结果。

第 2 步:处理 SpeechRecognitionEngine 事件

_speechRecognitionEngine.SpeechRecognized -= new EventHandler(SpeechRecognized);
_speechRecognitionEngine.SpeechHypothesized -= new EventHandler(SpeechHypothesizing);

_speechRecognitionEngine.SpeechRecognized += new EventHandler(SpeechRecognized);
_speechRecognitionEngine.SpeechHypothesized += new EventHandler(SpeechHypothesizing);

private void SpeechHypothesizing(对象发送者,
SpeechHypothesizedEventArgs e) {
///引擎实时结果
字符串 realTimeResults = e.Result.Text; }

private void SpeechRecognized(对象发送者,SpeechRecognizedEventArgs
e) {
///来自引擎的最终答案字符串finalAnswer =
e.结果.文本; }

就是这样。如果您想使用预先录制的 .wav 文件而不是麦克风,您可以使用

_speechRecognitionEngine.SetInputToWaveFile(pathToTargetWavFile);

而不是

_speechRecognitionEngine.SetInputToDefaultAudioDevice();

这些课程中有很多不同的选项,值得更详细地探索。

http://ellismis.com/2012/03/17/converting-or-transcribing-audio-to-text-using-c-and-net-system-speech/

Here is a complete example using C# and System.Speech

The code can be divided into 2 main parts:

configuring the SpeechRecognitionEngine object (and its required elements)
handling the SpeechRecognized and SpeechHypothesized events.

Step 1: Configuring the SpeechRecognitionEngine

_speechRecognitionEngine = new SpeechRecognitionEngine();
_speechRecognitionEngine.SetInputToDefaultAudioDevice();
_dictationGrammar = new DictationGrammar();
_speechRecognitionEngine.LoadGrammar(_dictationGrammar);
_speechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);

At this point your object is ready to start transcribing audio from the microphone. You need to handle some events though, in order to actually get access to the results.

Step 2: Handling the SpeechRecognitionEngine Events

_speechRecognitionEngine.SpeechRecognized -= new EventHandler(SpeechRecognized);
_speechRecognitionEngine.SpeechHypothesized -= new EventHandler(SpeechHypothesizing);

_speechRecognitionEngine.SpeechRecognized += new EventHandler(SpeechRecognized);
_speechRecognitionEngine.SpeechHypothesized += new EventHandler(SpeechHypothesizing);

private void SpeechHypothesizing(object sender,
SpeechHypothesizedEventArgs e) {
///real-time results from the engine
string realTimeResults = e.Result.Text; }

private void SpeechRecognized(object sender, SpeechRecognizedEventArgs
e) {
///final answer from the engine string finalAnswer =
e.Result.Text; }

That’s it. If you want to use a pre-recorded .wav file instead of a microphone, you would use

_speechRecognitionEngine.SetInputToWaveFile(pathToTargetWavFile);

instead of

_speechRecognitionEngine.SetInputToDefaultAudioDevice();

There are a bunch of different options in these classes and they are worth exploring in more detail.

http://ellismis.com/2012/03/17/converting-or-transcribing-audio-to-text-using-c-and-net-system-speech/

听,心雨的声音 2024-10-05 02:39:38

您可以检查Microsoft Speech API。我认为他们提供了一个 SDK,您可以使用它来实现您的目标。

You might check Microsoft Speech API. I think they provide a SDK that you can use for your objective.

小巷里的女流氓 2024-10-05 02:39:38

对于Java,Sun似乎有一个解决方案: javax.speech.recognition

For Java, it seems there is a solution from Sun: javax.speech.recognition

久夏青 2024-10-05 02:39:38

您可以使用SoX(声音处理程序的瑞士军刀)将音频文件转换为文本文件,其中数值对应于声音频率/音量。

我已经为之前的项目完成了此操作,但不知道确切的命令选项。

以下是该项目的链接:http://sox.sourceforge.net/Main/HomePage

You can use SoX (the Swiss Army knife of sound processing programs) to convert audio file to text file with numeric values corresponding to sound frequency/volume.

I have done it for a previous project but don't know the exact command options.

Here is a link to the project: http://sox.sourceforge.net/Main/HomePage

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文