Skip to content

Instantly share code, notes, and snippets.

@ryancastro
Created October 24, 2014 14:15
Show Gist options
  • Save ryancastro/366fa4b8f649496cde59 to your computer and use it in GitHub Desktop.
Save ryancastro/366fa4b8f649496cde59 to your computer and use it in GitHub Desktop.
Speaking through windows Voice API
def speak sentence
sentence = sentence.gsub /'/, "''"
`powershell.exe -c $speaker = new-object -com SAPI.SpVoice; $speaker.Speak('#{sentence}');`
end
speak "Hello."
@mattroyer
Copy link

require 'twitter'

class RunYourMouth
  def initialize
      client = Twitter::REST::Client.new do |config|
      config.consumer_key        = "YOUR_CONSUMER_KEY"
      config.consumer_secret     = "YOUR_CONSUMER_SECRET"
      config.access_token        = "YOUR_ACCESS_TOKEN"
      config.access_token_secret = "YOUR_ACCESS_SECRET"
    end

    client.user_timeline("matthewroyer", exclude_replies: true, include_rts: false).each do |user|
      speak user.text
    end
  end

  def speak sentence
    sentence = sentence.gsub /'/, "''"
    `powershell.exe -c $speaker = new-object -com SAPI.SpVoice;  $speaker.Speak('#{sentence}');`
  end
end

RunYourMouth.new

@mattroyer
Copy link

It only speaks the last 5 tweets of the user you put in, but I know somewhere in their api you can change how many it returns.

Also, I had to use the OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE hack to get it going because I don't have things setup right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment