Jump to content

Voice Tutorials


Ealric
 Share

Recommended Posts

This little gui will provide you with an idea on how to implement voice tutorials into your applications.

How it works:

The app contains a view menu with tutorials checked by default. Therefore when you start the application up, it will begin to start the tutorials (on by default). If you want to stop the tutorials at anytime, just press the "ESC" key and after it finishes the current tutorial line, it will stop. If you want to stop voice tutorials completely, go to the view menu and uncheck the Show Tutorials.

Right now the app simply has a basic intro tutorial system and a talk button that allows you to hear 2 more tutorial lines. If you implement this in your own application, it's pretty simple to use.

Just add a case to the _Tutorial() function:

Example:

Case 103

_Talk("Your tutorial line here")

Then somewhere in your application where you want the tutorial line referenced, just place the following:

_tutorial(103)

That's it. When the portion of your app reaches the area where the tutorial case hits, the tutorial will speak. Play around with it and have fun.

#include <GUIConstants.au3>

Global $configini = @ScriptDir & "\voice.ini"
Global $title = "Voice Tutorials"
Global $version = "1.0.0"

GuiCreate($title, 341, 150,(@DesktopWidth-341)/2, (@DesktopHeight-150)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
Global $oSay = GuiCtrlCreateButton("&Talk", 120, 70, 100, 30)
GUICtrlSetState($oSay, $GUI_DEFBUTTON)  

; VIEW MENU START
$viewmenu = GUICtrlCreateMenu("View", -1, 3)
$viewtutorialitem = GUICtrlCreateMenuItem("Show Tutorials", $viewmenu)
If IniRead($configini, "viewmenu", "tutorials", "on") = "on" Then
    GUICtrlSetState($viewtutorialitem, $GUI_CHECKED)
    $tutorial = 1
Else
    GUICtrlSetState($viewtutorialitem, $GUI_UNCHECKED)
    $tutorial = 0
EndIf
; VIEW MENU END

GuiSetState()

HotKeySet("{ESC}", "StopTutorials")

_tutorialintro()

While 1
        $msg = GuiGetMsg()
        Select
            case $msg = $oSay
                _tutorial(100)
                _tutorial(101)
            Case $msg = $viewtutorialitem
            If BitAND(GUICtrlRead($viewtutorialitem), $GUI_CHECKED) = $GUI_CHECKED Then
                GUICtrlSetState($viewtutorialitem, $GUI_UNCHECKED)
                IniWrite($configini, "viewmenu", "tutorials", "off")
                $tutorial = 0
            Else
                GUICtrlSetState($viewtutorialitem, $GUI_CHECKED)
                IniWrite($configini, "viewmenu", "tutorials", "on")
                $tutorial = 1
            EndIf
            Case $msg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
WEnd

; || Tutorial Functions

Func _tutorialintro()
    If $tutorial = 1 Then
        Sleep(1000)
        _tutorial(1)
        Sleep(0500)
        _tutorial(2)
        Sleep(0500)
        _tutorial(3)
        Sleep(0500)
        _tutorial(4)
    Else
        Return
    EndIf
EndFunc   ;==>_tutorialintro

; ## Voice tutorials listed below by case
Func _tutorial($iVAL)
    If $tutorial = 1 Then
        Switch $iVAL
            Case 1
                _Talk("Welcome to the " & $title & " program.")
            Case 2
                _Talk("version number " & $version)
            Case 3
                _Talk("If you wish to turn off these voice tutorials go to the view menu " & _ 
                    "and uncheck them.")
            Case 4
                _Talk("At anytime you may exit tutorial mode by pressing the escape key.")
            Case 100
                _Talk("My ROFLCopter goes soi soi soi soi soi soi soi")
            Case 101
                _Talk("I said a hip, hop, the hippie, the hippie to the hip hip hop " & _ 
                "a you dont stop the rock it to the bang bang boogie say up jumped the " & _ 
                "boogie to the rhythm of the boogie the beat")
        EndSwitch
    EndIf
EndFunc   ;==>_tutorial

Func StopTutorials()
    $tutorial = 0
EndFunc

Func _Talk($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak($s_text)
    $o_speech = ""
EndFunc   ;==>_Talk

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...