From: Helge Elvik Date: 2006-06-13T04:05:22+09:00 Subject: Re: Problem with win32ole, sapi5 Hi, Does anyone have any input on this old post? I'm having the same problem, but I can't find any response to the post anywhere. Basically it seems that win32ole doesn't discover that SpVoiceInstance.Voice is both a gettable and settable property: irb(main):053:0> Win32::SpVoice.new.ole_get_methods => [Status, Voice, AudioOutput, AudioOutputStream, Rate, Volume, AllowAudioOutpu tFormatChangesOnNextSet, EventInterests, Priority, AlertBoundary, SynchronousSpe akTimeout] irb(main):054:0> Win32::SpVoice.new.ole_put_methods => [Rate, Volume, AllowAudioOutputFormatChangesOnNextSet, EventInterests, Priori ty, AlertBoundary, SynchronousSpeakTimeout] irb(main):055:0> Is this a bug? The following is valid VB source code: Set V.Voice = V.GetVoices().Item(List1.ListIndex) So I'd expect something like this to work: require 'win32/sapi5' v = Win32::SpVoice.new v['Voice'] = v.GetVoices.Item(1) But it doesn't. I've tried all possible variants I can think of from the documentation: v.Voice = ... v.voice = ... v.Voice(...) v.voice(...) v['voice'] = ... v['Voice'] = ... v.setproperty('voice', ...) v.setproperty('Voice', ...) Basically I'd really love to get this to work properly. This weeks Ruby Quiz inspired me to give a go at a "personal trainer" for my treadmill sessions here at home. For now I've settled for a tiny VB .NET command line app that sets the voice I want, and takes text as an argument. I'd really love to have an all Ruby solution for this though. Regards, Helge Elvik Daniel Berger wrote: > Hi all, > > Ruby 1.8.4 (both installer and hand built) > win32-sapi 0.1.3 > > Why does my attempt to set the voice fail? > > C:\eclipse\workspace\win32-sapi>c:\ruby184\bin\irb > irb(main):001:0> require 'win32/sapi5' > => true > irb(main):002:0> include Win32 > => Object > irb(main):003:0> v = SpVoice.new > => # > irb(main):004:0> hash = {} > => {} > irb(main):005:0> v.getvoices.each{ |voice| > hash[File.basename(voice.Id)] = voice } > => nil > irb(main):006:0> hash > => {"MSMary"=>#, "MSSam"=>#, > "SampleTTSVoice"=>#, "MSMike"=> > #} > irb(main):007:0> v.voice = hash["MSMary"] > WIN32OLERuntimeError: > OLE error code:0 in > > HRESULT error code:0x80020003 > Member not found. > from (irb):8:in `method_missing' > from (irb):8 > > I also tried v.setproperty("voice",hash["MSMary"]) but got the same > result. > > Any ideas? > > Thanks, > > Dan -- Posted via http://www.ruby-forum.com/.