As our customer usually talk in different accent, like spanish ,indian and few other english accent. Is it possible to add multiple language accent in gather verb SPEECH RECOGNITION LANGUAGE?
Also I haven't found the "enhance" option in twilio studio.
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
//twiml.say("Testing voice command, please say something");
const gather = twiml.gather({
hints:"one, two, help, voicemail",
input:"speech",
partialResultCallback:"https:",
action:"https:",
language:"en-IN",
language:"en-US", //,en-US"
profanityFilter:true,
speechTimeout:15,
speechModel:"phone_call",
//"numbers_and_commands",
// enhanced:true
});
gather.say("Testing voice command, please say something and we will
transcribe it");
callback(null, twiml);
};
The recognized language is a single value. You would need to utilize a common way to ask what language they would like to interact with (say in English) before setting their primary language of choice.
https://www.twilio.com/docs/voice/twiml/gather#language
Related
The documentation found here, Known Limitations has a section stating:
Dual channel recording requires recordingStatusCallback to be set
The recordingStatusCallback attribute must be set in the Conference instruction attributes when enabling dual channel recording. See this support article for more information.
But the referenced support article does not provide any information on Dual Channel recordings.
There is a code snippet:
flex.Actions.addListener("beforeAcceptTask", (payload) => {
payload.conferenceOptions.record = 'true';
payload.conferenceOptions.recordingStatusCallback = 'https://example.com/recordingcallbackurl';
});
Which I believe generates a mono recording, not a dual channel (stereo) recording. Any suggestions where to look or can you provide some clarity around this? Not clear about the requirement for:
The recordingStatusCallback attribute must be set in the Conference instruction attributes
To generate a dual channel recording, I think you need to add the recordingChannels option, set to "dual":
flex.Actions.addListener("beforeAcceptTask", (payload) => {
payload.conferenceOptions.record = 'true';
payload.conferenceOptions.recordingStatusCallback = 'https://example.com/recordingcallbackurl';
payload.conferenceOptions.recordingChannels = 'dual'
});
I am trying to create a bot where when ever someone send a message about a type of food to the bot, then the bot will respond with the location that serves that food. However I am trying to establish context so that the conversation can flow more thoroughly.
I have tried nesting the if statement, and it gets it to display the message, but it would have to rely on the if-statement prior to be true before testing for the ones that comes after.
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from intents import fallback_intent, getLocation
import random
app = Flask(__name__)
location_fallback = ['What kind of restaurant are you seeking?', 'What kind? Nearby, Cheap or The best?']
welcome = ['hello', 'what\'s up', 'hey','hi', 'what\'s happening?']
near = ['near', 'nearby']
cheap = ['cheap', 'good for my pockets']
good = ['good', 'top rated']
intro_resp = ['''Hey! Welcome to Crave! This interactive platform connects you to the top foodies in the world! We provide you with the best food places where ever you are. The instructions are simple:
1. Save our number in your Phone as Crave.
2. Text us and tell us what type of food you are craving!
This is from python''', '''
Welcome to Crave! Are you ready to get some food for today?
1. Save our number in your Phone as Crave.
2. Text us and tell us what type of food you are craving!
''']
#app.route('/sms', methods=['GET','POST'])
def sms():
num = request.form['From']
msg = request.form['Body'].lower()
resp = MessagingResponse()
#welcome intent
if any(word in msg for word in welcome):
if any(near_word in msg for near_word in near):
resp.message('These are the location of places near you!')
print(str(msg.split()))
return str(resp)
elif any(cheap_word in msg for cheap_word in cheap):
resp.message('These are the location of places that are low cost to you!')
return str(resp)
elif any(good_word in msg for good_word in good):
resp.message('These are the best places in town!')
return str(resp)
else:
location_fallback[random.randint(0,1)]
resp.message(intro_resp[random.randint(0, 1)])
print(str(msg.split()))
return str(resp)
else:
resp.message(fallback_intent())
print(str(msg))
return str(resp)
if __name__ == '__main__':
app.run(debug=True)
I want the user to say 'hi'' or something related to initiate the bot, then I want the bot to prompt the user to ask what kind of food they would like. Then the bot will ask what parameters for the restaurant they would like(i.e Close, cheap, or good). Then the user will answer accordingly, and then the bot needs to use these parameters to search for the restaurant near them with these attributes.
Twilio developer evangelist here.
You could store this in many places, in cookies as part of the conversation with Twilio, in a database where you use the user's number as a key to look up previous messages, or even just in memory.
If you're looking for a more robust way to achieve this, with better natural language processing, have you checked out Twilio Autopilot? It stores the context of a conversation for you and is built to collect information before giving a response based on the complete set like you are doing.
I'm using the Tropo MVC classes and have a problem with changing the voice in the say. Setting the voice property of the say object does not seem to change the voice for example:
Say say1 = new Say("This is first voice");
say1.Voice = "susan";
Say say2 = new Say("This is the male voice");
say2.Voice = "dave";
List<Say> sayList = new List<Say>();
sayList.Add(say1);
sayList.Add(say2);
Script.Ask(null, null, new Choices("[1 DIGIT]", "dtmf", "#"), null, strArgs, true, sayList, Convert.ToSingle(action.Timeout));
The voice does not change. In fact it appears that the only way to change the voice is to set Script.Voice = "voice" which doesn't work for me as I have to handle language select in the first Ask which requires English voice followed by French voice.
Tropo also supports SSML, which is a super powerful markup language for mixing voices and adjusting voice tempo/cadence.
You can mix voices in a single Say command by doing something like:
new Say("<?xml version='1.0'?><speak>For English please press 1.<voice name='Carlos' xml:lang='es'>para el español por favor pulse 2</voice></speak>")
The inline XML is kinda yukkie but it gets the job done and learning SSML will allow you to create some really professional-sounding apps.
On many sites I saw printed out my current city where I am (eg "Hello to Berlin."). How they do that? What everything is needed for that?
I guess the main part is here javascript, but what everything I need for implementing something like this to my own app? (or is there some gem for Rails?)
Also, I would like to ask for one thing yet - I am interesting in the list of states (usually in select box), where user select his state (let's say Germany), according to the state value are in another select displayed all regions in Germany and after choosing a region are displayed respective cities in the selected region.
Is possible anywhere to obtain this huge database of states/cities/regions? Would be interesting to have something similar in our app, but I don't know, where those lists get...
You need a browser which supports the geolocation api to obtain the location of the user (however, you need the user's consent (an example here) to do so (most newer browsers support that feature, including IE9+ and most mobile OS'es browsers, including Windows Phone 7.5+).
all you have to do then is use JavaScript to obtain the location:
if (window.navigator.geolocation) {
var failure, success;
success = function(position) {
console.log(position);
};
failure = function(message) {
alert('Cannot retrieve location!');
};
navigator.geolocation.getCurrentPosition(success, failure, {
maximumAge: Infinity,
timeout: 5000
});
}
The positionobject will hold latitude and longitude of the user's position (however this can be highly inaccurate in less densely populated areas on desktop browsers, as they do not have a GPS device built in). To explain further: Here in Leipzig in get an accuracy of about 300 meters on a desktop computer - i get an accuracy of about 30 meters with my cell phone's GPS device.
You can then go on and use the coordinates with the Google Maps API (see here for reverse geocoding) to lookup the location of the user. There are a few gems for Rails, if you want. I never felt the need to use them, but some people seem to like them.
As for a list of countries/cities, we used the data obtainable from Geonames once in a project, but we needed to convert it for our needs first.
Internet Service Providers buy up big chunks of IP addresses, so what you're most likely seeing is a backtrace your IP to a known ISP. They have a database with ISP's and their location in the world, so they can try to see where you're from. You could try to use a site like http://www.ipaddresslocation.org/ to do your work. If you look around, there is bound to be a site that lets you enter an IP and get a location, so you just send a POST request to that site with your visitor's IP and scrape the location from the response.
Alternatively you could try to look for an ISP database that has location and what chunks of the IP range they have been allocated. You could probably find one for money, but a free one might be harder to find.
Alternatively, check out this free database http://www.maxmind.com/app/geolite
I've found getCurrentPosition() to often be inaccurate since it doesn't spend a lot of time waiting on the GPS to acquire a good accuracy. I wrote a small piece of JavaScript that mimics getCurrentPosition() but actually uses watch position and monitors the results coming back until they are better accuracy.
Here's how it looks:
navigator.geolocation.getAccurateCurrentPosition(onSuccess, onError, {desiredAccuracy:20, maxWait:15000});
Code is here - https://github.com/gwilson/getAccurateCurrentPosition
Correc syntax would be :
navigator.geolocation.getCurrentPosition(successCallBack, failureCallBack);
Use :
navigator.geolocation.getCurrentPosition(
function(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
console.log("Latitude : "+latitude+" Longitude : "+longitude);
},
function(){
alert("Geo Location not supported");
}
);
If you prefer to use ES6 and promises here is another version
function getPositionPromised() {
function successCb(cb) {
return position => cb(position);
}
function errorCb(cb) {
return () => cb('Could not retrieve geolocation');
}
return new Promise((resolve, reject) => {
if (window.navigator.geolocation) {
navigator.geolocation.getCurrentPosition(successCb(resolve), errorCb(reject));
} else {
return reject('No geolocation support');
}
})
}
And you can use it like this:
getPositionPromised()
.then(position => {/*do something with position*/})
.catch(() => {/*something went wrong*/})
Here is an another api to find out the location in PHP,
http://ipinfodb.com/ip_location_api.php
I have been using geoip.maxmind.com for quite a while and it works 100%. It can be accessed via HTTP requests.
//....
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
directionsService = new google.maps.DirectionsService();
var request = {
origin : new google.maps.LatLng(origin.lat, origin.lng),
destination : new google.maps.LatLng(destination.lat, destination.lng),
travelMode : google.maps.DirectionsTravelMode.DRIVING,
unitSystem : google.maps.DirectionsUnitSystem.METRIC,
region: 'de'
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
//....
As a result I get something like this
Head southwest on 吳江路/吴江路 toward 泰兴路/泰興路
Turn left at 茂名北路
Continue onto 茂名南路
Turn right at 淮海中路
Slight left to stay on 淮海中路
Turn left at 华山路/華山路
The instructions are English on my browser, and French on my French colleagues French Firefox, the street names are Chinese, I thought I requested information in German region: 'de'
Now ok, maybe the Chinese streets are not available in German, but setting region to gb, en, even zh seems to do nothing.
I really would like the text just to be one language, preferably English.
edit I am quite sure the street names are available in English, because when I use the Geocoder results are in English e.g Shimen Road (No.1)
edit2 with http://maps.google.com/maps/api/js?sensor=false&language=cs I am able to force the instructions into a language, but still the street names are stuck in Chinese. Using the geocoder api i can receive chinese street names that are Chinese translated into English/German/French (with fallback to english when german/french translations are missing) so why the directions street names is stuck on Chinese does not make sense. It could be just a flaw/deliberate on google's side, but I kind of doubt it.
Is there a reason
DirectionRequest doesn't have a parameter to specify language. The language is distinguished according to the language used for the map. The language is either specified as an optional language parameter in the <script> tag e.g.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=cs">
or if the parameter is not present the browser's preferred language is used.
If you want to use different language for the direction results and the map, you can use Google Directions API:
http://code.google.com/apis/maps/documentation/directions/
The result is JSON text. To use it easily, it should be sufficient just to convert it to an object.
The region parameter (both in the maps' DirectionRequest and Directions API) doesn't change the language, it serves other purpose. It affects results to be biased towards some region (e.g. the default result for 'Toledo' is the city in Ohio USA, if you want the one in Spain, use region=es to bias the results).