C # Voice Control

Source: Internet
Author: User

 

You cannot use controls to prevent playback delays or provide a memory method to store sound data.
The purpose is to play the sound accurately without the sound delay.

From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx

[Dllimport ("winmm. dll")]

 

You cannot use controls to prevent playback delays or provide a memory method to store sound data.
The purpose is to play the sound accurately without the sound delay.

From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx

[Dllimport ("winmm. dll")]
Public static extern long playsound (string name, long module, long flag );
[Dllimport ("winmm. dll")]
Private Static extern long mcisendstring (string lpstrcommand, string lpstrreturnstring, long length, long hwndcallback );
Private string m_musicname = "";
Private void playmusic ()
{
M_musicname = "+ tool. readinfo (" promptmusicfile ") + """";
If (m_musicname.length = 0)
Return;
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
Mcisendstring (@ "open" + m_musicname, "", 0, 0 );
Mcisendstring (@ "play" + m_musicname, "", 0, 0 );
}
Catch
{
}

}

Private void stopmusic ()
{
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
}
Catch {}
}

You can play the wav files in the memory as follows:

// API Definition
Private const int snd_async = 0x1;
Private const int snd_memory = 0x4;

[Dllimport ("winmm. dll")]
Private Static extern int sndplaysounda (byte [] lpszsoundname, int uflags );

// Add blip1.wav to the project and set it as an embedded Resource
// Read it into the memory for backup
Type T = This. GetType ();
System. reflection. Assembly A = T. assembly;
System. Io. Stream stream = A. getmanifestresourcestream (T. namespace + ".blip1.wav ");
Byte [] BA = new byte [stream. Length];
Stream. Read (BA, 0, ba. Length );
Stream. Close ();

// Play Cache
Sndplaysounda (BA, snd_memory );

Note:

Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it.

Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource.

Assembly assem = assembly. getexecutingassembly ();
Stream stream = assem. getmanifestresourcestream (
"Ums. datadefinition." + strobjname + ". xml ");

 

For more information, see explain.

 

You cannot use controls to prevent playback delays or provide a memory method to store sound data.
The purpose is to play the sound accurately without the sound delay.

From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx

[Dllimport ("winmm. dll")]
Public static extern long playsound (string name, long module, long flag );
[Dllimport ("winmm. dll")]
Private Static extern long mcisendstring (string lpstrcommand, string lpstrreturnstring, long length, long hwndcallback );
Private string m_musicname = "";
Private void playmusic ()
{
M_musicname = "+ tool. readinfo (" promptmusicfile ") + """";
If (m_musicname.length = 0)
Return;
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
Mcisendstring (@ "open" + m_musicname, "", 0, 0 );
Mcisendstring (@ "play" + m_musicname, "", 0, 0 );
}
Catch
{
}

}

Private void stopmusic ()
{
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
}
Catch {}
}

You can play the wav files in the memory as follows:

// API Definition
Private const int snd_async = 0x1;
Private const int snd_memory = 0x4;

[Dllimport ("winmm. dll")]
Private Static extern int sndplaysounda (byte [] lpszsoundname, int uflags );

// Add blip1.wav to the project and set it as an embedded Resource
// Read it into the memory for backup
Type T = This. GetType ();
System. reflection. Assembly A = T. assembly;
System. Io. Stream stream = A. getmanifestresourcestream (T. namespace + ".blip1.wav ");
Byte [] BA = new byte [stream. Length];
Stream. Read (BA, 0, ba. Length );
Stream. Close ();

// Play Cache
Sndplaysounda (BA, snd_memory );

Note:

Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it.

Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource.

Assembly assem = assembly. getexecutingassembly ();
Stream stream = assem. getmanifestresourcestream (
"Ums. datadefinition." + strobjname + ". xml ");

 

For more information, see explain.

You cannot use controls to prevent playback delays or provide a memory method to store sound data.
The purpose is to play the sound accurately without the sound delay.
From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx
[Dllimport ("winmm. dll")]
Public static extern long playsound (string name, long module, long flag );
[Dllimport ("winmm. dll")]
Private Static extern long mcisendstring (string lpstrcommand, string lpstrreturnstring, long length, long hwndcallback );
Private string m_musicname = "";
Private void playmusic ()
{
M_musicname = "\" "+ tool. readinfo (" promptmusicfile ") + "\"";
If (m_musicname.length = 0)
Return;
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
Mcisendstring (@ "open" + m_musicname, "", 0, 0 );
Mcisendstring (@ "play" + m_musicname, "", 0, 0 );
}
Catch
{
}
}
Private void stopmusic ()
{
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
}
Catch {}
}
You can play the wav files in the memory as follows:
// API Definition
Private const int snd_async = 0x1;
Private const int snd_memory = 0x4;
[Dllimport ("winmm. dll")]
Private Static extern int sndplaysounda (byte [] lpszsoundname, int uflags );
// Add blip1.wav to the project and set it as an embedded Resource
// Read it into the memory for backup
Type T = This. GetType ();
System. reflection. Assembly A = T. assembly;
System. Io. Stream stream = A. getmanifestresourcestream (T. namespace + ".blip1.wav ");
Byte [] BA = new byte [stream. Length];
Stream. Read (BA, 0, ba. Length );
Stream. Close ();
// Play Cache
Sndplaysounda (BA, snd_memory );

Note:
Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it.

Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource.

Assembly assem = assembly. getexecutingassembly ();
Stream stream = assem. getmanifestresourcestream (
"Ums. datadefinition." + strobjname + ". xml ");

There are also some ways to refer to the http://hi.baidu.com/%D3%DE%D6%D0%D7%F7%C0%D6/blog/item/0a621344de1aec85b2b7dc92.html
Public static extern long playsound (string name, long module, long flag );
[Dllimport ("winmm. dll")]
Private Static extern long mcisendstring (string lpstrcommand, string lpstrreturnstring, long length, long hwndcallback );
Private string m_musicname = "";
Private void playmusic ()
{
M_musicname = "\" "+ tool. readinfo (" promptmusicfile ") + "\"";
If (m_musicname.length = 0)
Return;
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
Mcisendstring (@ "open" + m_musicname, "", 0, 0 );
Mcisendstring (@ "play" + m_musicname, "", 0, 0 );
}
Catch
{
}

}

Private void stopmusic ()
{
Try
{
Mcisendstring (@ "close" + m_musicname, "", 0, 0 );
}
Catch {}
}

You can play the wav files in the memory as follows:

// API Definition
Private const int snd_async = 0x1;
Private const int snd_memory = 0x4;

[Dllimport ("winmm. dll")]
Private Static extern int sndplaysounda (byte [] lpszsoundname, int uflags );

// Add blip1.wav to the project and set it as an embedded Resource
// Read it into the memory for backup
Type T = This. GetType ();
System. reflection. Assembly A = T. assembly;
System. Io. Stream stream = A. getmanifestresourcestream (T. namespace + ".blip1.wav ");
Byte [] BA = new byte [stream. Length];
Stream. Read (BA, 0, ba. Length );
Stream. Close ();

// Play Cache
Sndplaysounda (BA, snd_memory );

Note:

Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it.

Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource.

Assembly assem = assembly. getexecutingassembly ();
Stream stream = assem. getmanifestresourcestream (
"Ums. datadefinition." + strobjname + ". xml ");

 

For more information, see explain.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.