Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/python
  2.  
  3. from __future__ import generators
  4. import feedparser
  5. import os, sys
  6. import datetime
  7. import time
  8. import string
  9. import threading
  10. import select
  11.  
  12.  
  13.  
  14. def chunks(seq, size):
  15.     startpos = 0
  16.     endpos = size - 1
  17.     while endpos  < len(seq):
  18.         while seq[endpos] != ' ':
  19.             endpos -= 1
  20.         yield seq[startpos:endpos + 1]
  21.         startpos = endpos + 1
  22.         endpos += size
  23.     yield seq[startpos:]
  24.  
  25. size=100
  26. announce = 'Good morning...This is your wakeup call'               
  27.        
  28.  
  29. os.system('rm /mnt/storage/Jarvis/out.wav')
  30.  
  31. w = feedparser.parse('http://pipes.yahoo.com/pipes/pipe.run?_id=81beeb11da4ba773848c4a81b7198718&_render=rss')
  32. n = feedparser.parse('http://pipes.yahoo.com/pipes/pipe.run?_id=e189632e9213ee8054da152ee9ceab35&_render=rss')
  33.  
  34. weather = w.entries[0].description + '.' + w.entries[1].description + '.' + w.entries[2].description
  35. c=1
  36. r=0
  37. news = ''
  38.  
  39. for lines in n.entries:
  40.     news += ',.. Headline. ' + n.entries[c].title + '.'
  41.     c+=1
  42.     if (c > 5):
  43.         break
  44.  
  45.    
  46. position=0
  47. z=0
  48. y=0                
  49. completeannounce = announce + ',..Here is your weather for today...' + weather + '...Here is your latest news,..' + news
  50. chop = [x for x in chunks(completeannounce,size)]
  51. os.system('rm /mnt/storage/Jarvis/stream*.wav')
  52. for segments in chop:
  53.     os.system('mplayer -cache 5096 "http://translate.google.com/translate_tts?tl=en&q=%s" -vc null -vo null -ao pcm:fast:waveheader:file=/mnt/storage/Jarvis/stream%s-%s.wav' % (chop[position], str(z), str(y),))
  54.     print str(len(chop[position]))
  55.     if y > 8:
  56.         y = 1
  57.         z+=1
  58.     else:
  59.         y+=1
  60.     position+=1
  61.  
  62. os.system('sox /mnt/storage/Jarvis/*.wav /mnt/storage/Jarvis/out.wav')
  63. os.system('rm /mnt/storage/Jarvis/stream*.wav')
  64.    
  65. #os.system('mplayer /mnt/storage/Jarvis/out.wav')
  66.    
  67. print chop