REBOL

 

Talk-to-me - Source Code

Choose a voice, type your text and listen !
Author: DideC
File size: 1K
Return to index

 

REBOL [
    title: "Speach generator"
    author: "Didier Cadieu"
    version: 1.0.0
    date: 27-march-2004
]

voix: [
    "Crystal (US English)"
    "Mike (US English)"
    "Rich (US English)"
    "Lauren (US English)"
    "Claire (US English)"
    "Rosa (Latin Am. Spanish)"
    "Klara (German)"
    "Reiner (German)"
    "Alain (French)"
    "Juliette (French)"
    "Charles (UK English)"
    "Audrey (UK English)"
]

wave: none
check: 0
old-voice: none

speak: func [str [string!] voice /local p][
    if any [check <> check: checksum str old-voice <> old-voice: voice] [
        wave: read/binary/custom http://hegel.research.att.com/tts/cgi-bin/nph-talk reduce [
            'POST
            rejoin ["txt=" str "&voice=" voice]
        ]
    ]
    p: open sound://
    insert p load copy wave
    wait p
    close p
]

view layout [
    style vt vtext 100 right
    backdrop effect [gradient 1x1 20.180.20 20.20.120]
    vh1 "Speach generator"
    across
    vt "Voice to use :"
    f-voice: choice 200 data voix return
    vt "Text to say :"
    f-text: area wrap return
    tabs [128]
    tab
    button "Speak" [
        if not empty? f-text/text [
            speak f-text/text first parse f-voice/text none
        ]
    ]
    button "Save wave" [
        if all [
            wave
            f: request-file/save/keep/only/title/filter "Save voice in wave file" "save" "*.wav"
        ] [
            if not find f ".wav" [append f ".wav"]
            write/binary f wave
        ]
    ] return
    tab vtext "Click here to know how it works ?" [browse http://www.research.att.com/projects/tts/index.html]
]