In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how vbs calls Chinese voice to make your computer listen to your commands. I hope you will get something after reading this article. Let's discuss it together.
If your machine itself is equipped with office, you may not need to install the following software. Because my machine is equipped with openoffice, I installed it in advance.
Speechsdk51.exe
CNSpeechPackage.msi
These two softwares. If you let the computer read it aloud, refer to the following code
The copy code is as follows:
ReadAllTextFile=CreateObject ("Scripting.FileSystemObject") .OpenTextFile (Wscript.Arguments (0), 1) .ReadAll
Function RegExpTest (patrn, strng)
Dim regEx, Match, Matches' create variables.
Set regEx = New RegExp 'establishes the regular expression.
RegEx.Pattern = patrn 'sets the mode.
RegEx.IgnoreCase = True 'sets whether it is case-sensitive.
RegEx.Global = True 'sets full availability.
Set Matches = regEx.Execute (strng) 'performs the search.
For Each Match in Matches' traverses the Matches collection.
RetStr = RetStr & Match.value& ""
RetStr = RetStr & vbCRLF
Next
RegExpTest = RetStr
End Function
Set objVoice = CreateObject ("SAPI.SpVoice")
Set objVoice.Voice = objVoice.GetVoices ("Name=Microsoft Simplified Chinese") .Item (0)
ObjVoice.Rate = 3 'Speed:-10pm 100
ObjVoice.Volume = 100' Sound: 0100
ObjVoice.Speak RegExpTest ("[\ u4e00 -\ u9fa5]", ReadAllTextFile)
Or after installing speechsdk51.exe, you can refer to it.
C:\ Program Files\ Microsoft Speech SDK 5.1\ Samples\ Scripts\ SimpleTTS\ SimpleTTS.html this file.
If you let the computer listen to your orders, here is the vbs code
The copy code is as follows:
'=
'Name: CommandPC.VBS
'AUTHOR: HUAYING
'DATE: 2005-1-31
'=
Dim CommandDictionary 'command dictionary object
The Dim WshShell 'WshShell object provides access to the local Windows program.
Dim ScriptComplete 'Program end Flag
Dim SR 'speech recognition (Speech Recognition) object
Command Syntax object of Dim Grammar 'speech recognition
'initialize the command dictionary object, and add commands according to your own needs
Set CommandDictionary = CreateObject ("Scripting.Dictionary")
CommandDictionary.Add "go online", "" C:\ Program Files\ Internet Explorer\ iexplore.exe "'pay attention to the number of double quotes
CommandDictionary.Add "calculator", "calc"
CommandDictionary.Add "notepad", "notepad"
CommandDictionary.Add "empty pickup", "freecell"
Set WshShell = CreateObject ("WScript.Shell") 'create WshShell object
ScriptComplete = False 'initialization program end flag
'create a speech recognition object, invoke the syntax defined by "Command.XML", and start the speech recognition engine
Set SR = WScript.CreateObject ("SAPI.SpSharedRecoContext", "RecoContext_")
Set Grammar = SR.CreateGrammar
Grammar.CmdLoadFromFile "x.xml", SLODynamic
Grammar.CmdSetRuleIdState 0, 1
MsgBox "Hello, master, please."
Waiting for your voice command (microphone needs to be installed)
'The program ends when the command end command is recognized
Do
WScript.Sleep 1000
Loop Until ScriptComplete
MsgBox "Welcome to talk to me again, goodbye!"
Your voice command is recognized
Sub RecoContext_Recognition (ByVal StreamNumber,ByVal StreamPosition,ByVal RecognitionType,ByVal Result)
Text = Result.PhraseInfo.GetText 'get the commands recognized by the speech recognition engine
If Text "Command end" Then
WshShell.Run CommandDictionary.Item (Text) 'your command is executed by the WshShell object Run method
Else
ScriptComplete = true 'program end flag
End If
End Sub
= =
X.xml source code
The copy code is as follows:
surf the Internet
Calculator
Notepad
Empty pick-up
End of command
If you run this vbs directly on a Chinese machine, it is very likely that a 0x80045052 error will occur. The solution:
Control Panel-Voice-Voice recognition Tab-change to Microsoft Simplified Chinese
After reading this article, I believe you have a certain understanding of "how to use vbs to make your computer listen to your commands". If you want to know more about it, please follow the industry information channel. Thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.