IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Voir le flux RSS

Madmac

Comment rendre Ruby bavard.

Noter ce billet
par , 10/05/2022 à 15h37 (4174 Affichages)
Vous pouvez faire parler Ruby avec tts.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'tts'

# dependance sudo apt-get install mpg123
# Will download "Hello World!.mp3" to your current directory
# Supported languages: ["zh", "en", "it", "fr"]
"Hello World!".to_file "en"
"bonjour tout le monde!".to_file "fr"
# i18n
"人民代表代表人民".to_file "zh"

# Save the file to a specific location
"Light rain with highs of 5 degrees".to_file "en", "~/weather.mp3"

# Supports large text files, as the gem will batch up the requests to Google (as each request max 100 chars)
text = "People living on the east coast of England have been warned to stay away from their homes because of further high tides expected later. The tidal surge that hit the UK is said to have been the worst for 60 years, with thousands abandoning their homes."
text.to_file "en"

#Direct playback (require mpg123 installed and in PATH with a POSIX system)
"Established in 1853, the University of Melbourne is a public-spirited institution that makes distinctive contributions to society in research, learning and teaching and engagement.".play

#Direct playback in other language (2 times)
 "Oggi il tempo è buono, andiamo in gita di esso.".play("it", 2)

#RTL Arabic language
"اليوم كان الطقس جيدا، ونحن نذهب في نزهة منه.".play("ar")

"bonjour tout le monde!".play("fr")
Vous devez préalablement installé la gemme "tts"
Et le programme mpg123

Code : Sélectionner tout - Visualiser dans une fenêtre à part
sudo apt install mpg123
Pour Debian et ses dérivés.

À noter, cet utilitaire utilise un service de Google pour fonctionner en temps réels. Mais peut également produire le mp3. Et enfin ce programme ne fonctionne pas quand il est lancer d'un éditeur.

Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Viadeo Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Twitter Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Google Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Facebook Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Digg Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Delicious Envoyer le billet « Comment rendre Ruby bavard. » dans le blog MySpace Envoyer le billet « Comment rendre Ruby bavard. » dans le blog Yahoo

Catégories
Programmation

Commentaires