joaoricardo000 / whatsapp-bot-seed

A small python framework to create a whatsapp bot, with regex-callback message routing.
727 stars 245 forks source link

Fix image search with bing #21

Closed joyarzun closed 8 years ago

joyarzun commented 8 years ago

Google API image search is deprecated. This PR replace with Bing API

joaoricardo000 commented 8 years ago

Thanks for the pull request! Great solution, that really fix the image search. Right now I'm on vacation, probably sometime next week I'll merge it. Thanks again.

joyarzun commented 8 years ago

You're welcome. In reality it is the same thing you did it. Thanks to you. For tts, I don't know how make it work. But not is important to me.

relima commented 8 years ago

for tts, I am now using espeak:

def send_tts_portugues(self, message, match):
    ttstext=match.group("text")
    escapes = ''.join([chr(char) for char in range(1, 32)])
    ttstext.translate(None, escapes)
    id = hashlib.md5(ttstext.encode('utf-8')).hexdigest()
    filetmp = ''.join(["/tmp/tts", id, str(int(time.time()))[:-2], ".wav"])       
    subprocess.call(["espeak", "-v", "pt+f5", "-s", "120", "-k", "-20", "-w", filetmp, "'"+ttstext+"'"])
    self.video_sender.send_by_path(jid=message.getFrom(), path=filetmp)

Microsoft Azure Marketplace has a service that is free up to 5000 requests per month for voice/tts. But it does not support portuguese.

joyarzun commented 8 years ago

Yes, Microsoft supported portuguese. The project is moved to Project Oxford

ghost commented 8 years ago

27 TTS with eSpeak

x23piracy commented 8 years ago

Hi,

bing picture search is working well after getting a bing api key :)

Regards X23

joaoricardo000 commented 8 years ago

Thanks, working great! Sorry for the delay to merge on master... Great PR...

joaoricardo000 commented 8 years ago

Just to write it down somewhere...

Create an account on Microsoft and subscribe to the search service here (free for 5000 p/ month) https://datamarket.azure.com/dataset/bing/search

Get the API key here: https://datamarket.azure.com/account/keys

Update the config.py and success!

andremacola commented 8 years ago

Maybe we can put Google Image again with: https://github.com/BirdAPI/Google-Search-API

relima commented 8 years ago

Perhaps the image should be downloaded directly from Bing`s cache instead of from the original source. I have experienced many issues when connecting to the original server in order to download the image.

In addition, Bing`s cache provides optimized images, which are less demanding in regards to bandwidth, saving us a lot of server cost.

joyarzun commented 8 years ago

@andremacola At first glance, it should work with this API. Feel free to make a PR with the changes. @relima You are right. The original source is not always the best option. Can you make a PR with a parameter that you can switch from original to cached version?

relima commented 8 years ago

@andremacola Done. https://github.com/joaoricardo000/whatsapp-bot-seed/pull/63