Como hacer que diga el nombre de la canción que toca con Mpd (Music Player Daemon). [ESP-ENG]

in blurtech •  last year  (edited)

immagine.png

Como muchos se habrán dado cuenta hacer esto posible para todos los reproductores es poco pensable.

El ejemplo está hecho pensando en MPD.

Consideraciones y dependencias:

Sólo será capaz de pronunciar en un idioma a la vez, imaginen como pronunciará canciones en otros idiomas.
Idiomas distintos al inglés se instalan por separado, aquí les digo además como instalar el de español.
Si se usa un lenguaje occidental ni siquiera trata de leer Chino (tal vez pinyin), Japonés (romaji sí) ni Coreano.
Bash.
pulseaudio.
mpd.
mpc.
festival + idioma.

MPD (Music Player Daemon) es un reproductor de audio que maneja una arquitectura servidor-cliente. MPD se ejecuta en el fondo como un daemon, gestiona listas de reproducción y una base de datos, y hace uso de muy pocos recursos. Para hacer uso de una interfaz gráfica, es necesario un cliente adicional. Más información puede obtenerse en su página web.

Mpd es un demonio que se ejecuta en segundo plano, y necesita clientes para ser controlado, en este caso esos clientes son esos "reproductores" que les mostré anteriormente. Es capaz de manejar listas de reproducción y bases de datos de la música. Si bien les mostré esos clientes gráficos también los hay de consola.

Iniciemos paso por paso:

1.- Instalar y configurar MPD.

Todo lo que necesitan está en la wiki de ArchLinux:

Pueden instalar Sonata, por supuesto, como cliente o cualquiera de los otros que les mostré anteriormente o busquen más clientes para MPD.

Ya saben que en vez de apt-get tienen que usar slapt-get, pacman, ccr, zypper, yum, emerge, entropy, etc dependiendo de la distribución, aunque es probable que no vengan en sus paquetes oficiales y consigan un binario, un archivo de contrucción o compilarlo directamente.
Es importante que seleccionen la salida pulseaudio, así no se queda estancado alsa y dice el nombre de la canción en el inicio.

2.- Intalar mpc.

Mpc es un cliente para mpd, pueden instalar el cliente que quieran pero este es una dependencia que deben instalar para el propósito de este post. Normalmente lo podrán instalar con el sistema de paquetería de su sistema:
El link para el código fuente:
http://mpd.wikia.com/index.php?title=Client:Mpc&oldid=5273

3.- Instalar Festival y configurarlo.

Debian/Ubuntu:
apt-get install festival festvox-ellpc11k
En el caso de Arch:
pacman -S festival
yaourt -S festvox-ellpc11k
Vamos a editar el pkgbuild porque no se actualiza desde el 2011.
mkdir -p $startdir/pkg/usr/share/festival
cp -r festival/lib/voices $startdir/pkg/usr/share/festival
Hay que cambiarlas por estas:
mkdir -p $startdir/pkg/$pkgname/usr/share/festival
cp -r festival/lib/voices $startdir/pkg/$pkgname/usr/share/festival
festvox-ellpc11k es el paquete para pasar de texto a voz el idioma español:
Ahora hay que configurarlo para que use pulseaudio:

Sólo lo probé con Arch y las saqué de la wiki de esta misma.
En su archivo ~/.festivalrc añadan estas lineas:
(Parameter.set 'Audio_Required_Format 'aiff)
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Command "paplay $FILE --client-name=Festival --stream-name=Speech")
Asegurense que tienen instalado paplay
4.- Copien este script a /usr/bin como root:
sudo nano /usr/bin/tsn
#! /bin/bash
function helpp {
cat << EOF

Debes dar argumentos para señalar el idioma, todos sin guión en excepción de "-h"
"-h" para mostrar esta ayuda
"a" para el idioma por defecto (inglés)
"b" para el idioma español
EOF
}
if [[ ! -n "$@" ]] ; then
helpp
else
if [[ ! "$@" == "-h" ]]; then
pro=$(ps -ef | grep $0 | grep bash | wc -l)
if [[ ! "$pro" = "2" ]]; then
echo "Ya está corriendo otra instancia del programa"
exit 1
fi
if [[ "$1" == "a" ]]; then
while true; do
mpc current --wait | festival --tts
done
fi
if [[ "$1" == "b" ]]; then
while true; do
mpc current --wait | festival --language spanish --tts
done
fi
fi
fi
if [[ "$1" = "-h" ]]; then
helpp
fi
Siempre deben dar argumentos:
$tsn a para que diga en inglés las canciones (Artista/Título)
$tsn b para que las diga en español (Artista/Título)
$tsn -h Les muestra una ayuda parecida a esta

SEPARADOR

As many will have realised, making this possible for all players is unthinkable.

The example is made with MPD in mind.

Considerations and dependencies:

It will only be able to pronounce in one language at a time, imagine how it will pronounce songs in other languages.
Languages other than English are installed separately, here is also how to install Spanish.
If you use a western language, don't even try to read Chinese (maybe pinyin), Japanese (romaji yes) or Korean.
Bash.
pulseaudio.
mpd.
mpc.
festival + language.

MPD (Music Player Daemon) is an audio player that handles a server-client architecture. MPD runs in the background as a daemon, manages playlists and a database, and uses very few resources. To make use of a graphical interface, an additional client is required. More information can be found on their website.

Mpd is a daemon that runs in the background, and needs clients to be controlled, in this case those clients are those "players" I showed you earlier. It is able to handle playlists and music databases. While I showed you those graphical clients, there are also console clients.

Let's start step by step:

Install and configure MPD.

Everything you need is on the ArchLinux wiki:

You can install Sonata, of course, as a client or any of the others I showed you earlier or look for more MPD clients.

You already know that instead of apt-get you have to use slapt-get, pacman, ccr, zypper, yum, emerge, entropy, etc depending on the distribution, although it is likely that they don't come in their official packages and you can get a binary, a build file or compile it directly.
It is important that you select the pulseaudio output, so it doesn't get stuck on alsa and says the name of the song at startup.

Install mpc.

Mpc is a client for mpd, you can install any client you want but this is a dependency that you must install for the purpose of this post. Normally you will be able to install it with your system's packaging system:

The link for the source code:
http://mpd.wikia.com/index.php?title=Client:Mpc&oldid=5273

Install Festival and configure it.

Debian/Ubuntu:
apt-get install festival festvox-ellpc11k
For Arch:
pacman -S festival
yaourt -S festival festvox-ellpc11k
Let's edit the pkgbuild because it is not updated since 2011.
mkdir -p $startdir/pkg/usr/share/festival
cp -r festival/lib/voices $startdir/pkg/usr/usr/share/festival
You have to change them to these:

mkdir -p $startdir/pkg/$pkgname/usr/share/festival
cp -r festival/lib/voices $startdir/pkg/$pkgname/usr/share/festival
festvox-ellpc11k is the package to convert the Spanish language from text to speech:
Now you have to configure it to use pulseaudio:

I only tested it with Arch and got it from the Arch wiki.
In your ~/.festivalrc file add these lines:
(Parameter.set 'Audio_Required_Format 'aiff)
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Command "paplay $FILE --client-name=Festival --stream-name=Speech")
Make sure you have paplay installed
Copy this script to /usr/bin as root:
sudo nano /usr/bin/tsn
/usr/bin/bash
function helpp {
cat << EOF

You must give arguments to point to the language, all without a hyphen except for "-h".
"-h" to display this help
"a" for the default language (English)
"b" for the Spanish language
EOF
}
if [[ ! -n "$@" ]]] ; then
helpp
else
if [[ ! "$@" == "-h" ]]; then
pro=$$(ps -ef | grep $0 | grep bash | wc -l)
if [[ ! "$pro" = "2" ]]; then
echo "Another instance of the program is now running".
exit 1
fi
if [[ "$1" == "a" ]]; then
while true; do
mpc current --wait | festival --tts
done
fi
if [[ "$1" == "b" ]]; then
while true; do
mpc current --wait | festival --language spanish --tts
done
fi
fi
fi
if [[ "$1" = "-h" ]]; then
helpp
fi
You must always give arguments:
$tsn a to say in English the songs (Artist/Title).
$tsn b to say them in Spanish (Artist/Title)
$tsn -h Shows them a help similar to this one

banner-traductor-globe-g308afd03f_1280.jpg

banner-propiedad-imagenes.png

Home Page oficial del proyecto: /Official home page of the project: MPD

Descarga / Download.

Screenshots / Capturas de pantallas:

MPD

Blogs, Sitios Web y Redes Sociales / Blogs, Webs & Social NetworksPlataformas de Contenidos/ Contents Platforms
Mi Blog / My BlogLos Apuntes de Tux
Red Social Twitter / Twitter Social Network@hugorep

separador-firma-rounded-in-photoretrica.png


Posted from https://blurtlatam.intinte.org

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!