# Need help with win32-sapi

**URL:** <https://www.ruby-forum.com/t/need-help-with-win32-sapi/150627>\
**Category:** Ruby\
**Created:** [October 10, 2008, 4:25pm UTC](https://www.ruby-forum.com/t/need-help-with-win32-sapi/150627 "2008-10-10T16:25:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 10, 2008, 4:25pm UTC](https://www.ruby-forum.com/t/need-help-with-win32-sapi/150627/1 "2008-10-10T16:25:10Z")

</div>

Hi all,

I try to do some ‘text to speach’ stuff using win32-sapi.

I run the example from the rdoc but I get the error info. I wonder how  
to fix it.

Thanks,

Li

C:\Users\Alex\>irb  
irb(main):001:0\> require ‘win32/sapi5’  
=\> true  
irb(main):002:0\> include Win32  
=\> Object  
irb(main):003:0\>  
irb(main):004:0\* v = SpVoice.new  
=\> #Win32::SpVoice:0x337212c  
irb(main):005:0\> v.Speak(“Shall we play a game?”)  
WIN32OLERuntimeError: Speak  
OLE error code:80040154 in   
  
HRESULT error code:0x80020009  
Exception occurred.  
from (irb):5:in `method\_missing’  
from (irb):5  
irb(main):006:0\>

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 14, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/need-help-with-win32-sapi/150627/2 "2008-10-14T17:05:59Z")

</div>

Li Chen wrote:

> Hi all,
> 
> I try to do some ‘text to speach’ stuff using win32-sapi.
> 
> I run the example from the rdoc but I get the error info. I wonder how  
> to fix it.
> 
> Thanks,
> 
> Li
> 
> C:\Users\Alex\>irb  
> irb(main):001:0\> require ‘win32/sapi5’  
> =\> true  
> irb(main):002:0\> include Win32  
> =\> Object  
> irb(main):003:0\>  
> irb(main):004:0\* v = SpVoice.new  
> =\> #Win32::SpVoice:0x337212c  
> irb(main):005:0\> v.Speak(“Shall we play a game?”)  
> WIN32OLERuntimeError: Speak  
> OLE error code:80040154 in   
>   
> HRESULT error code:0x80020009  
> Exception occurred.  
> from (irb):5:in `method\_missing’  
> from (irb):5  
> irb(main):006:0\>

Hi all,

I solve this problem by myself as following(it crosses my mind when I  
read other articles on the internet):

Start\>control panel\>Speech on Xp or(text to speech on vista)\>Voice  
selection\>apply

Then run the script above and it works!!! I guess I don’t set up the  
voice correctly at the beginning.

Li
