Skip to content

Commit

Permalink
Merge pull request #255 from MyRobotLab/move-startRadio
Browse files Browse the repository at this point in the history
Update 1_AudioFile.py
  • Loading branch information
hairygael authored Dec 10, 2024
2 parents 85f53d8 + 7f79529 commit 4b944a5
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 24 deletions.
24 changes: 0 additions & 24 deletions gestures/startRadio.py

This file was deleted.

87 changes: 87 additions & 0 deletions peers/ProgramAB/fr-FR/aiml/jukebox.aiml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
<pattern>END_PLAYLIST</pattern>
<template>Je suis arrivé à la fin de la playlist. Je remonte au début de la liste.</template>
</category>

<!-- AIML POUR ECOUTER LA RADIO -->
<category>
<pattern>* RADIO *</pattern>
<template>Okay, je lance la radio <star index="2"/>.
Expand All @@ -258,6 +260,27 @@
<li value="rire et chansons">
<think><set name="radio">"http://cdn.nrjaudio.fm/adwz1/fr/30407/mp3_128.mp3?origine=fluxradios"</set></think>
</li>
<li value="france">
<think><set name="radio">"http://icecast.radiofrance.fr/francemusiqueconcertsradiofrance-midfi.mp3"</set></think>
</li>
<li value="chérie fm">
<think><set name="radio">"http://cdn.nrjaudio.fm/adwz1/fr/55495/mp3_128.mp3"</set></think>
</li>
<li value="europe 1">
<think><set name="radio">"http://wr.lmn.fm/e1-wr5.mp3"</set></think>
</li>
<li value="jazz">
<think><set name="radio">"http://jazz-wr01.ice.infomaniak.ch/jazz-wr01-128.mp3"</set></think>
</li>
<li value="nostalgie">
<think><set name="radio">"http://cdn.nrjaudio.fm/adwz1/fr/30605/mp3_128.mp3?"</set></think>
</li>
<li value="nrj">
<think><set name="radio">"http://cdn.nrjaudio.fm/adwz2/fr/30001/mp3_128.mp3?origine=fluxradios"</set></think>
</li>
<li value="rfm">
<think><set name="radio">"http://stream.rfm.fr/rfm-wr4.mp3"</set></think>
</li>
</condition>
<oob>
<mrl>
Expand All @@ -270,6 +293,48 @@
</template>
</category>

<category>
<pattern>* MUSIQUE CLASSIQUE</pattern>
<template>Voici une radio classique.
<oob>
<mrl>
<service>python</service>
<method>exec</method>
<param>startRadio("http://icecast.radiofrance.fr/francemusiqueconcertsradiofrance-midfi.mp3")</param>
</mrl>
</oob>
<srai>APPSMILE</srai>
</template>
</category>

<category>
<pattern>* MUSIQUE DE JAZZ</pattern>
<template>Voici une radio de jazz
<oob>
<mrl>
<service>python</service>
<method>exec</method>
<param>startRadio("http://jazz-wr01.ice.infomaniak.ch/jazz-wr01-128.mp3")</param>
</mrl>
</oob>
<srai>APPSMILE</srai>
</template>
</category>

<category>
<pattern>* MUSIQUE DE FILM</pattern>
<template>Voici une station radio de musique de films
<oob>
<mrl>
<service>python</service>
<method>exec</method>
<param>startRadio("http://icecast.radiofrance.fr/francemusiquelabo-midfi.mp3")</param>
</mrl>
</oob>
<srai>APPSMILE</srai>
</template>
</category>

<category>
<pattern>STOP LA RADIO</pattern>
<template>Voilà, la radio est éteinte.
Expand All @@ -290,4 +355,26 @@
<srai>STOP LA RADIO</srai>
</template>
</category>

<category>
<pattern>STOPPE LA RADIO</pattern>
<template>
<srai>STOP LA RADIO</srai>
</template>
</category>
<category>

<pattern>STOPPE LA MUSIQUE</pattern>
<template>
<srai>STOP LA RADIO</srai>
</template>
</category>

<category>
<pattern>ÉTEINS LA RADIO</pattern>
<template>
<srai>STOP LA RADIO</srai>
</template>
</category>

</aiml>
24 changes: 24 additions & 0 deletions services/1_AudioFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,27 @@ def previousPlay():
else:
i01.warn("i01.chatBot needs to be started")

def startRadio(station):
if runtime.isStarted("i01.audioPlayer"):
audioPlayer = runtime.getService("i01.audioPlayer")
audiocfg = audioPlayer.getConfig()
print("Radio started")
if audiocfg.stream == 0:
audiocfg.stream = 1
audioPlayer.save()
audioPlayer.apply(audiocfg)
audioPlayer.broadcastState()
print(station)
audioPlayer.playFile(station)

def stopRadio():
if runtime.isStarted('i01.audioPlayer'):
audioPlayer = runtime.getService('i01.audioPlayer')
audioPlayer.stop()
print("Radio stopped")
audiocfg = audioPlayer.getConfig()
if audiocfg.stream == 1:
audiocfg.stream = 0
audioPlayer.save()
audioPlayer.apply(audiocfg)
audioPlayer.broadcastState()

0 comments on commit 4b944a5

Please sign in to comment.