Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
py-tts-script
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="griimnak" data-source="post: 441488" data-attributes="member: 35695"><p><span style="font-size: 18px"><strong>py-tts-script</strong></span></p><p></p><p>I think someone here would find use in this script</p><p></p><p>This is a ~40 line Python script that returns text to speech.</p><p>Works with Python2 & 3, and requires no pip modules.</p><p></p><p>Tested on Windows and Linux, unfortunately I don't have a mac to test this on but I'm sure it should work like linux.</p><p></p><p>Source: <a href="https://github.com/griimnak/py-tts-script" target="_blank">https://github.com/griimnak/py-tts-script</a></p><p></p><p></p><p><span style="font-size: 18px"><strong>Usage</strong></span></p><p>[CODE=Bash]</p><p>python speak.py "Hello world"</p><p>[/CODE]</p><p></p><p>or use it as a module</p><p>[CODE=Python]</p><p>import speak</p><p></p><p>speak.speak_windows("Hello world")</p><p># speak.speak_linux("Hello world")</p><p>[/CODE]</p><p></p><p></p><p><span style="font-size: 18px"><strong>How it works</strong></span></p><p></p><p>If you're on linux or mac you may need to install the `say` package.</p><p></p><p>For windows, no packages are needed. It uses powershell's built in speech synthesizer</p><p></p><p>[CODE=Python]</p><p>import os</p><p>import sys</p><p>""" usage: python speak.py "Hello world"</p><p></p><p> or use as a module:</p><p> import speak</p><p> speak.speak_windows("Hello world")</p><p>"""</p><p></p><p>__version__ = "0.1.0"</p><p>__author__ = "github.com/griimnak"</p><p>__all__ = ["speak_windows", "speak_linux"]</p><p></p><p>def speak_windows(speech):</p><p> os.system(</p><p> "powershell.exe -ExecutionPolicy ByPass "+</p><p> "param([String]$text='"+speech+"'); Add-Type -AssemblyName System.speech;"+</p><p> "$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;"+</p><p> "$speak.SelectVoice('Microsoft Zira Desktop'); $speak.Speak($text)"</p><p> )</p><p></p><p>def speak_linux(speech):</p><p> os.system('say "'+speech+'"')</p><p></p><p>def _cli_output(arg):</p><p> print('[working]')</p><p> if os.name == 'nt':</p><p> return speak_windows(arg)</p><p> return speak_linux(arg)</p><p></p><p>if __name__ == '__main__':</p><p> try:</p><p> _cli_output(sys.argv[1])</p><p> except IndexError:</p><p> print('''</p><p>usage: python speak.py "Hello world"</p><p></p><p>or use as a module:</p><p>import speak</p><p>speak.speak_windows("Hello world")''')</p><p> exit()</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="griimnak, post: 441488, member: 35695"] [SIZE=5][B]py-tts-script[/B][/SIZE] I think someone here would find use in this script This is a ~40 line Python script that returns text to speech. Works with Python2 & 3, and requires no pip modules. Tested on Windows and Linux, unfortunately I don't have a mac to test this on but I'm sure it should work like linux. Source: [URL]https://github.com/griimnak/py-tts-script[/URL] [SIZE=5][B]Usage[/B][/SIZE] [CODE=Bash] python speak.py "Hello world" [/CODE] or use it as a module [CODE=Python] import speak speak.speak_windows("Hello world") # speak.speak_linux("Hello world") [/CODE] [SIZE=5][B]How it works[/B][/SIZE] If you're on linux or mac you may need to install the `say` package. For windows, no packages are needed. It uses powershell's built in speech synthesizer [CODE=Python] import os import sys """ usage: python speak.py "Hello world" or use as a module: import speak speak.speak_windows("Hello world") """ __version__ = "0.1.0" __author__ = "github.com/griimnak" __all__ = ["speak_windows", "speak_linux"] def speak_windows(speech): os.system( "powershell.exe -ExecutionPolicy ByPass "+ "param([String]$text='"+speech+"'); Add-Type -AssemblyName System.speech;"+ "$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;"+ "$speak.SelectVoice('Microsoft Zira Desktop'); $speak.Speak($text)" ) def speak_linux(speech): os.system('say "'+speech+'"') def _cli_output(arg): print('[working]') if os.name == 'nt': return speak_windows(arg) return speak_linux(arg) if __name__ == '__main__': try: _cli_output(sys.argv[1]) except IndexError: print(''' usage: python speak.py "Hello world" or use as a module: import speak speak.speak_windows("Hello world")''') exit() [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
py-tts-script
Top