def play(request): if request.method == "POST": tex = request.POST.get("speak") ttsWatson = TtsWatson('42657070-d2ed-4d8d-bac3-05d505e42b9a', 'ePrw5TcBlL6N', 'en-US_AllisonVoice') num = word_tokenize(tex) numlength = len(num) - 1 tcount = 0 newtex = "" for n in num: word = n.lower() sent = "".join(word) if tcount == 0: newtex = newtex + sent else: newtex = newtex + " " + sent tcount += 1 print(newtex) memo = Memory.objects.filter(query=newtex) if len(tex) != 0 and memo: for me in memo: ttsWatson.play(me.reply) return render(request, "page/index.html") else: ttsWatson.play("Sorry, I didn't understand") return render(request, "page/index.html") else: return render(request, "page/front.html")
def main(): requests.packages.urllib3.disable_warnings() defaultConfig = { 'url': 'https://stream.watsonplatform.net/text-to-speech/api', 'user': '******', 'password': '******', 'voice': 'en-US_AllisonVoice', 'chunk': 2048 } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-tts-watson.yml' parser = argparse.ArgumentParser( description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('text_to_transform', action='store', nargs='+') args = parser.parse_args() conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print "Config file '" + args.configFile + "' doesn't exist." print "Creating it ..." user = raw_input("Watson user: "******"Watson password: "******" ".join(args.text_to_transform))
class TtsWatsonRos: CONFIG_FILE = "config.yml" def __init__(self): currentDir = os.path.dirname(os.path.realpath(__file__)) configFile = currentDir + "/../" + self.CONFIG_FILE conf = anyconfig.load(configFile) bconf = bunch.bunchify(conf) self.ttsWatson = TtsWatson(bconf.user, bconf.password, bconf.voice, bconf.url, bconf.chunk) def playSound(self, data): self.ttsWatson.play(data.data)
class TtsWatsonRos: CONFIG_FILE = "config1.yml" def __init__(self): currentDir = os.path.dirname(os.path.realpath(__file__)) configFile = currentDir + "/../" + self.CONFIG_FILE conf = anyconfig.load(configFile) bconf = bunch.bunchify(conf) self.ttsWatson = TtsWatson(bconf.user, bconf.password, bconf.voice, bconf.url, bconf.chunk) def playSound(self, data): print("hi") #self.ttsWatson.play('hello') self.ttsWatson.play(data.data)
class TtsWatsonRos: CONFIG_FILE = "config.sample.yml" def __init__(self): currentDir = os.path.dirname(os.path.realpath(__file__)) configFile = currentDir + "/../" + self.CONFIG_FILE conf = anyconfig.load(configFile) bconf = bunch.bunchify(conf) self.ttsWatson = TtsWatson(bconf.user, bconf.password, bconf.voice, bconf.url, bconf.chunk) def playSound(self, data): if data.data == True: self.ttsWatson.play("Requested action executed") else: self.ttsWatson.play("No command to execute")
class TtsWatsonRos: CONFIG_FILE = "config1.yml" global pre pre = 1 def __init__(self): currentDir = os.path.dirname(os.path.realpath(__file__)) configFile = currentDir + "/../" + self.CONFIG_FILE conf = anyconfig.load(configFile) bconf = bunch.bunchify(conf) self.ttsWatson = TtsWatson(bconf.user, bconf.password, bconf.voice, bconf.url, bconf.chunk) def playSound(self, data): global user_input global context print(data.data) #if(pre!=data.data): i = 0 while True: i = i + 1 if i > 5: break # Send message to Assistant service. user_input = data.data response = service.message(workspace_id=workspace_id, input={'text': user_input}, context=context) # If an intent was detected, print it to the console. if response.result['intents']: print('Detected intent: #' + response.result['intents'][0]['intent']) # Print the output from dialog, if any. Assumes a single text response. if response.result['output']['text']: print(response.result['output']['text'][0]) self.ttsWatson.play(response.result['output']['text'][0]) break # Update the stored context with the latest received from the dialog. context = response.result['context']
def main(): py3_input_conversion = lambda x: input( x) if sys.version_info.major >= 3 else raw_input(x) requests.packages.urllib3.disable_warnings() defaultConfig = { 'url': 'https://stream.watsonplatform.net/text-to-speech/api', 'user': '******', 'password': '******', 'voice': 'en-US_AllisonVoice', 'chunk': 2048 } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-tts-watson.yml' parser = argparse.ArgumentParser(description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('text_to_transform', action='store', nargs='+') args = parser.parse_args() conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print("Config file '" + args.configFile + "' doesn't exist.") print("Creating it ...") user = py3_input_conversion("Watson user: "******"Watson password: "******" ".join(args.text_to_transform))
def alison_speak(self, text): engine = TtsWatson(self.watson_username, self.watson_password, 'en-US_AllisonVoice') engine.play(text) pass
from tts_watson.TtsWatson import TtsWatson ttsWatson = TtsWatson( '*****@*****.**', 'Nnnoman@007', 'en-US_AllisonVoice' ) # en-US_AllisonVoice is a voice from watson you can found more to: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/text-to-speech/using.shtml#voices ttsWatson.play("The text which i want to be a sound")
print("Google Speech Recognition thinks you said " + msg) except sr.UnknownValueError: print("Google Speech Recognition could not understand audio") except sr.RequestError as e: print("Could not request results from Google Speech Recognition service; {0}".format(e)) #msg = r.recognize_google(audio,language='FR').encode("utf-8") #print "Message " + msg if msg: params = urllib.urlencode({'msg':msg}) print "\nUtilisateur : " + msg print "J'envois la requête" #urllib2.urlopen('http://localhost:8080/chatterbot',params) response = sendToChatterbot(msg); requests.packages.urllib3.disable_warnings(InsecureRequestWarning) print "\n Bot : "+response response = response.encode('utf-8') # engine = pyttsx.init() # engine.setProperty('rate', 150) # engine.say(response) # engine.runAndWait() ttsWatson = TtsWatson('c7b754a7-30af-478b-ad09-50d6599fee4a', '4PiXRAE4QPpU', 'fr-FR_ReneeVoice') ttsWatson.play(response) print "Requête délivrée" msg = "" else: print "Pas de message"
from tts_watson.TtsWatson import TtsWatson ttsWatson = TtsWatson('*****@*****.**', 'P652568323', 'en-US_AllisonVoice') ttsWatson.play('Hello World')
from tts_watson.TtsWatson import TtsWatson ttsWatson = TtsWatson('', '', 'en-US_AllisonVoice') texttospeak = 'Aman Dalal' a = ttsWatson.play(texttospeak)
# using python text to speech import pyttsx3 #Note ## for this to work properly install python-espeak package ## use `sudo apt-get install python-espeak` in ubuntu engine = pyttsx3.init() engine.say(input_text) engine.startLoop() ## using google's text to speech package from gtts import gTTS print('Enter text to convert to audio...\n') input_text = raw_input() tts = gTTS(text=input_text, lang='en') tts.save("audio.mp3") ## IBM watson text to speech from tts_watson.TtsWatson import TtsWatson ttsWatson = TtsWatson('watson_user', 'watson_password', 'en-US_AllisonVoice') ttsWatson.play("Hello kartheek")
client = oauth.Client(consumer,access_token) timeline_endpoint = "https://api.twitter.com/1.1/search/tweets.json?q=%23SaturdayIBMProgramming" ttsWatson = TtsWatson('userfromwatson', 'passwordfromwatson', 'en-US_AllisonVoice') def remove_accents(input_str): nkfd_form = unicodedata.normalize('NFKD', input_str) only_ascii = nkfd_form.encode('ASCII', 'ignore') return only_ascii while 1: try: response, data = client.request(timeline_endpoint) data = json.loads(data) usernameTw = remove_accents(data['statuses'][0]['user']['screen_name']) textoTw = remove_accents(data['statuses'][0]['text']) if AUX1!=textoTw or AUX2!=usernameTw: print "Read Twitter" AUX1=textoTw AUX2=usernameTw ttsWatson.play(textoTw + " " + usernameTw) else: time.sleep(6) except: data = "" print "Nothing to show" time.sleep(6) continue
text_a = open("input.txt").read() text_b = open("input2.txt").read() import os import markovify import time import subprocess import itertools import requests import json from watson_developer_cloud import TextToSpeechV1 text_to_speech = TextToSpeechV1( iam_apikey='sz6H8LevNTGD8wn8_fBqFZ61lrUDtuHAFwuD1TFaguPr', url='https://gateway-wdc.watsonplatform.net/text-to-speech/api') from tts_watson.TtsWatson import TtsWatson tts = TtsWatson("**Username**", "**Password**", "en-US_Allisonvoice") tts.play("Test")
from gtts import gTTS import os #tts = gTTS(text="Good morning", lang="en") from tts_watson.TtsWatson import TtsWatson userName = "******" password = "******" ttsWatson = TtsWatson(userName, password, "en-AllisonVoice") text = 'Hello world' ttsWatson.play(text)
from tts_watson.TtsWatson import TtsWatson ttsWatson = TtsWatson('watson_user', 'watson_password', 'en-US_AllisonVoice') ttsWatson.play("Hello World")
# -*- coding: utf-8 -*- # Boucle permettant de tenir une conversation avec le robot #pico = 'sh ~/Documents/Cherry/pico.sh' #Chemin vers le script pico, qui lance pico2wave import sys import os import pypot import urllib2 import urllib import pyttsx import string from tts_watson.TtsWatson import TtsWatson # import requests # from requests.packages.urllib3.exceptions import InsecureRequestWarning #requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # engine = pyttsx.init() # engine.setProperty('rate', 150) # engine.say(response) # engine.runAndWait() ttsWatson = TtsWatson('9ab9e322-6ac9-4d11-a93f-10c19667a013', 'G4QF16oBGpIC', 'fr-FR_ReneeVoice') # chaine = "" # tab = sys.argv[1].split("_"); # for i in tab : # chaine+=i+" " # ttsWatson.play(chaine.encode('utf-8')) ttsWatson.play("Bonjour")