Thread: [tuxdroid-user] Automatically detect language
Status: Beta
Brought to you by:
ks156
From: Georges D. <geo...@la...> - 2007-08-08 13:14:02
|
Hi I just wrote a little piece of code that read the locale in order to determine which language tux should speak. Here it is : def find_language(): env=os.environ['LANG'] dict1={ 'en_US':'US', #American English 'nl_BE':'B'} #Belgian Dutch dict2={ 'fr':'FR', #French 'de':'D', #Deutsch 'en':'GB', #British English 'ar':'AR', #Arabic 'da':'DK', #Danish 'es':'E', #Spanish 'it':'I', #Italian 'nl':'NL', #Dutch 'nb':'NO', #Norwegian 'pt':'P', #Portuguese 'sv':'S'} #Swedish if dict1.has_key(env[:5]): return dict1[env[:5]] elif dict2.has_key(env[:2]): return dict2[env[:2]] else: return 'US' I think it can be useful. Maybe even in the svn (in order to determine default language, and advice about downloading languages). What do you think about it ? |
From: neimad <ror...@gm...> - 2007-08-08 19:04:05
|
Georges Dubus <geo...@la...> writes: > I think it can be useful. Maybe even in the svn (in order to determine default > language, and advice about downloading languages). > > What do you think about it ? Why have 2 dictionaries ? A single one would do fine. Damien |
From: Georges D. <geo...@la...> - 2007-08-09 12:34:30
|
On Wednesday 08 August 2007 21:08:33 neimad wrote: > Georges Dubus <geo...@la...> writes: > > I think it can be useful. Maybe even in the svn (in order to determine > > default language, and advice about downloading languages). > > > > What do you think about it ? > > Why have 2 dictionaries ? A single one would do fine. > > Damien > English and Dutch have one particularity : there are two variants, depending on the country. The first dictionary check for a specific country, whereas the second one check only the language. With one dictionary, it could make the difference between US and GB. Georges |
From: neimad <ror...@gm...> - 2007-08-09 16:48:52
|
Georges Dubus <geo...@la...> writes: > The first dictionary check for a specific country, whereas the second one > check only the language. > > With one dictionary, it could make the difference between US and GB. Yeah, I missed the :5 / :2 part :-$ Damien |
From: David B. <da...@ja...> - 2007-08-13 09:32:24
|
On Thu, 09 Aug 2007 18:53:29 +0200, neimad <ror...@gm...> wrote: > Georges Dubus <geo...@la...> writes: > >> The first dictionary check for a specific country, whereas the second >> one >> check only the language. >> >> With one dictionary, it could make the difference between US and GB. > > Yeah, I missed the :5 / :2 part :-$ Missed exactly the same :-) Thanks for the patch, Georges. |
From: Georges D. <geo...@la...> - 2007-08-10 09:10:41
|
Hi Just an idea, more or less linked to that. When I select a voice that is not present on the system, male american is selected. Maybe there could be a warning telling that the voice can be downloaded. Can it be done in the api, or is the "fallback" to english deeper in the daemon ? Georges |
From: David B. <da...@ja...> - 2007-08-13 09:49:21
|
On Fri, 10 Aug 2007 11:10:22 +0200, Georges Dubus <geo...@la...> wrote: > Hi > > Just an idea, more or less linked to that. When I select a voice that is > not > present on the system, male american is selected. Maybe there could be a > warning telling that the voice can be downloaded. > > Can it be done in the api, or is the "fallback" to english deeper in the > daemon ? > The fallback to the male american voice is done in tuxttsd so you don't really have access to that but in case you want some modifications, just add a new issue to the trackers and that will be taken into account for next release. On the other hand, you can get a list of all installed voices from the events in the API. That list is used in the latest GTDI so only the installed languages are shown. This list could also be used to enforce the language selection. David |
From: Georges D. <geo...@la...> - 2007-08-13 10:28:17
|
On Monday 13 August 2007 11:49:15 David Bourgeois wrote: > > The fallback to the male american voice is done in tuxttsd so you don't > really have access to that but in case you want some modifications, just > add a new issue to the trackers and that will be taken into account for > next release. > > On the other hand, you can get a list of all installed voices from the > events in the API. That list is used in the latest GTDI so only the > installed languages are shown. This list could also be used to enforce the > language selection. > > David I don't have my tux with me, so I can't check. Is the tux.tts.authorized_voices_list the list you're talking about ? If it's that, I'll write a patch that check whether the selected language is present, and return a message containing the url if not. Once done, maybe I can add a new function based on that code that would determine which language is to used. Maybe it could be used during the install in order to dowload the needed language. Georges |
From: David B. <da...@ja...> - 2007-08-13 12:40:57
|
On Mon, 13 Aug 2007 12:28:07 +0200, Georges Dubus <geo...@la...> wrote: > On Monday 13 August 2007 11:49:15 David Bourgeois wrote: >> >> The fallback to the male american voice is done in tuxttsd so you don't >> really have access to that but in case you want some modifications, just >> add a new issue to the trackers and that will be taken into account for >> next release. >> >> On the other hand, you can get a list of all installed voices from the >> events in the API. That list is used in the latest GTDI so only the >> installed languages are shown. This list could also be used to enforce >> the >> language selection. >> >> David > > > I don't have my tux with me, so I can't check. Is the > tux.tts.authorized_voices_list the list you're talking about ? Yes, that's it. (I don't know that myself, I'm just asking Rémi all the time ;-) ) This list returns all installed languages, and as soon as you select one, the list is updated and only includes English and the second language you choosed. (The Acapela license only allow you to use English and a second language simultaneously.) > > If it's that, I'll write a patch that check whether the selected > language is > present, and return a message containing the url if not. > > Once done, maybe I can add a new function based on that code that would > determine which language is to used. Maybe it could be used during the > install in order to dowload the needed language. From my point of view, I think tux.tts.select_voice should only allow the languages that are in tux.tts.authorized_voices_list to be selected, as the others won't. Then it can return an error if the language doesn't exist, or return the URL if the language exists but is not installed. David |
From: Georges D. <geo...@la...> - 2007-08-15 08:02:00
|
> From my point of view, I think tux.tts.select_voice should only allow the > languages that are in tux.tts.authorized_voices_list to be selected, as > the others won't. Then it can return an error if the language doesn't > exist, or return the URL if the language exists but is not installed. I think this patch is what you want: Index: api/python/trunk/tuxapi_class.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- api/python/trunk/tuxapi_class.py (r=C3=A9vision 462) +++ api/python/trunk/tuxapi_class.py (copie de travail) @@ -4258,8 +4258,12 @@ """ if speaker not in SPK_VOICE_LIST: if self.parent.print_warnings: =2D print " Invalid speaker" + print " Invalid voice" return + if speaker not in self.authorized_voices_list: + if self.parent.print_warnings: + print " This voice is not available on the system. You can= =20 download it at http://www.tuxisalive.com/downloads" + return if (pitch<100) or (pitch>330): if self.parent.print_warnings: print " Pitch not in range (100 - 330)" > This list returns all installed languages, and as soon as you select one, > the list is updated and only includes English and the second language you > choosed. (The Acapela license only allow you to use English and a second > language simultaneously.) I couldn't see the list update by myself (I didn't try so much), but if it= =20 only contain two languages, then this script doesn't work as we want. I see= =20 no way to know whether it list all the languages, or only two. Any idea ? |