Code Examples
  Home arrow Code Examples arrow Page 4 - Binary File, Array Scripting Secrets
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Binary File, Array Scripting Secrets
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2009-03-25

    Table of Contents:
  • Binary File, Array Scripting Secrets
  • Writing Binary Files with the FileSystemObject
  • Removing an array element
  • Adding Voice to Your Scripts

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Binary File, Array Scripting Secrets - Adding Voice to Your Scripts


    (Page 4 of 4 )

    Adding Voice to Your Scripts

    It’s nice when your script can pass information back to the user, but it’s sometimes inconvenient to display a message box for simple notifications. And what if you want to add some accessibility to your scripts for the sight-impaired?  Why not teach your scripts how to speak?

    That’s right!  Adding voice to your scripts can be both useful and fun.  Not only can you teach your scripts to speak, but you can also teach them to read through the use of Microsoft’s Speech API (SAPI).

    strText = "Hi, I am a talking script."

     

    Set objVoice = CreateObject("SAPI.SpVoice")

    objVoice.Speak strText

    As you can see, making a script talk is extremely easy.  You simply connect to the SAPI Voice object and use the Speak method.  The text will immediately be read back by the Text-To-Speech Engine.

    Const ForReading = 1

    Set objVoice = CreateObject("SAPI.SpVoice")

    Set objFso = CreateObject("Scripting.FileSystemObject")

    Set objFile = objFso.OpenTextFile("C:speechraven.txt", ForReading)

     

    Do Until objFile.AtEndOfStream

       objVoice.Speak objFile.ReadLine

    Loop

    With slightly more effort, your script can read the contents of a text file.  Here I’m using the FileSystemObject to open and read a simple text file line by line while passing that text to the Speech API.

    You can find the files used in this example here: speech.zip

    Set objVoice = CreateObject("SAPI.SpVoice")

    Set objStream = CreateObject("SAPI.SpFileStream")

     

    objStream.Open "C:speechraven.wav"

    objVoice.SpeakStream objStream

    Not only can you render text as speech, but the Speech API can also play back audio wave files.  SAPI provides the SpFileStream object for opening and streaming the audio file.  This time the SpeakStream method is used to play back the stream.

    Admittedly, playing wav files in your scripts doesn’t seem all that useful to a system admin.  After all, it’s probably not necessary for your scripts to serenade the end user.  However, considering the fact that most system sounds are in wave format, this takes on a more practical use.

    Set objVoice = CreateObject("SAPI.SpVoice")

    Set objFile = CreateObject("SAPI.SpFileStream.1")

     

    objFile.Open "C:WindowsMediaTada.wav"

    objVoice.Speakstream objFile

    And that, ladies and gentlemen wraps up the third issue of Nilpo’s scripting secrets.  Go out and have a little fun with these techniques.  Try writing a login script that will welcome the user by name!  Until next time, keep coding!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek