语音/语音转文字

发布于 2024-10-11 11:08:14 字数 1539 浏览 9 评论 0原文

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

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

发布评论

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

评论(6

凡间太子 2024-10-18 11:08:14

您可以使用 CMU Sphinx,因为它是非常开放且可扩展的解决方案,我认为它可以在客户端和服务器端使用:

http://cmusphinx.sourceforge.net/

如果您正在寻找 Microsoft 桌面解决方案,那么您可以使用 SAPI:

http://msdn.microsoft.com/en-us/magazine/cc163663.aspx

在服务器端,您可以使用 Microsoft 统一通信,但请考虑将许可视为好:

http://www.microsoft.com/uc/en/gb/ default.aspx

更新:

该线程也有一些很好的参考:

C# 语音识别 - 这是用户所说的吗?

You can use CMU Sphinx as it is pretty open and scalable solution and I think it can be used at both client and server side:

http://cmusphinx.sourceforge.net/

If you are looking for a Microsoft desktop solution then you can use SAPI:

http://msdn.microsoft.com/en-us/magazine/cc163663.aspx

On server side, you can use Microsoft Unified Communication, but do consider licencing as well:

http://www.microsoft.com/uc/en/gb/default.aspx

Update:

This thread has also some good reference:

C# Speech Recognition - Is this what the user said?

提笔书几行 2024-10-18 11:08:14

以下是使用 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-trancribing-audio-to-text-using-c-and-net-system-speech/

Here is a complete example using C# and System.Speech for converting from speech to text

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-18 11:08:14

请参阅使用 C++ 调用和使用 Windows 语音识别

其中表示:

Microsoft 为 Windows 的客户端和服务器版本提供语音识别引擎。两者都可以使用 C++ 或 .NET 语言进行编程。用于 C++ 编程的传统 API 称为 SAPI。客户端和服务器语音的 .NET 框架命名空间是 System.Speech 和 Microsoft.Speech。

SAPI 文档 - http://msdn.microsoft.com/ en-us/library/ms723627(VS.85).aspx

用于客户端识别的 .NET 命名空间是 System.Speech - http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx。 Windows Vista 和 7 包含语音引擎。

用于服务器识别的 .NET 命名空间是 Microsoft.Speech,10.2 版本的完整 SDK 可在 http://www.microsoft.com/downloads/en/details.aspx?FamilyID=1b1604d3-4f66-4241-9a21-90a294a5c9a4。语音引擎可免费下载。

许多早期的问题已经解决了这个问题。请参阅基于语音识别的原型语音识别和语音合成入门SAPI 和 Windows 7 问题 例如。

See Using c++ to call and use Windows Speech Recognition

Which says:

Microsoft provides speech recognition engines for both client and server versions of Windows. Both can be programmed with C++ or with .NET languages. The traditional API for programming in C++ is known as SAPI. The .NET framework namepsaces for client and server speech are System.Speech and Microsoft.Speech.

SAPI documentation - http://msdn.microsoft.com/en-us/library/ms723627(VS.85).aspx

The .NET namespace for client recognition is System.Speech - http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx. Windows Vista and 7 include the speech engine.

The .NET namespace for server recognition is Microsoft.Speech and the complete SDK for the 10.2 version is available at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=1b1604d3-4f66-4241-9a21-90a294a5c9a4. The speech engine is a free download.

Lots of earlier questions have addressed this. See Prototype based on speech recognition , getting started with speech recognition and speech synthesis , and SAPI and Windows 7 Problem for examples.

梦明 2024-10-18 11:08:14

我想使用 C# 和 .NET,但其他语言也足够了。如果您愿意使用 C++ 节日

I'd like to use C# and .NET, but other languages will suffice. Check this if you are open to C++ Festival

始终不够 2024-10-18 11:08:14

每个 Windows 操作系统中都有一个用于 Text2Speach 的内置 DLL。您将在 c:\Programs\Shared Folders\Microsoft Shared\Speech\sapi.dll (sAPI - speach api) 中找到相应的 dll - 我不太确定路径 - 但无论如何您可以搜索 sapi.dll。

之后您可以使用以下代码片段

SpVoice oVoice = new SpVoice();
oVoice.Voice = oVoice.GetVoices("","").Item(0); // 0 indicating what kind of speaker you want
oVoice.Volume = 50;
oVoice.Speak("hello world", SpeechVoiceSpeakFlags.SVSFDefault);
oVoice = null;

There is a builtIn DLL in every Windows OS for Text2Speach. You will find the according dll in c:\Programs\Shared Folders\Microsoft Shared\Speech\sapi.dll (sAPI - speach api) - I am not quite sure about the path - but in anyway you may search for sapi.dll.

Afterwards you may use the following code snippet

SpVoice oVoice = new SpVoice();
oVoice.Voice = oVoice.GetVoices("","").Item(0); // 0 indicating what kind of speaker you want
oVoice.Volume = 50;
oVoice.Speak("hello world", SpeechVoiceSpeakFlags.SVSFDefault);
oVoice = null;
一世旳自豪 2024-10-18 11:08:14

对于文本到语音的转换,您必须遵循 3 个步骤:

1.添加 System.Speech 引用。

2.添加标题:

使用System.Speech;

使用系统.语音.合成;

3.添加以下代码,其中textBox1 是文本框默认名称。

            SpeechSynthesizer speaker = new SpeechSynthesizer();
            speaker.Rate = 1;
            speaker.Volume = 100;
            speaker.Speak(textBox1.Text);

For text to speech conversion you have to follow 3 steps:

1.Add System.Speech reference.

2.Add Headers:

using System.Speech;

using System.Speech.Synthesis;

3.Add the following code where textBox1 is a Text Box default name.

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