Skip to content

Commit

Permalink
Address feedback from #25
Browse files Browse the repository at this point in the history
Update documentation
Add missing system deps to Dockerfile
  • Loading branch information
NeonDaniel committed Nov 7, 2023
1 parent 0c4c2bd commit ec12067
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ LABEL vendor=neon.ai \
ai.neon.name="neon-iris"

ENV OVOS_CONFIG_BASE_FOLDER neon
ENV OVOS_CONFIG_FILENAME diana.yaml
ENV OVOS_CONFIG_FILENAME neon.yaml
ENV XDG_CONFIG_HOME /config

RUN apt update && \
apt install -y ffmpeg

ADD . /neon_iris
WORKDIR /neon_iris

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ iris:
languages:
- en-us
- uk-ua
webui_chatbot_label: "Neon AI"
webui_mic_label: "Speak with Neon"
webui_input_placeholder: "Chat with Neon"
```
## Interfacing with a Diana installation
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions neon_iris/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def _send_audio(self, audio_file: str, lang: str,
{"lang": lang,
"audio_data": audio_data,
"utterances": []},
# TODO: `utterances` patching mq connector
username, user_profiles)
serialized = {"msg_type": message.msg_type,
"data": message.data,
Expand Down
20 changes: 12 additions & 8 deletions neon_iris/web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import librosa
import soundfile as sf


class GradIOClient(NeonAIClient):
def __init__(self, lang: str = None):
config = Configuration()
Expand Down Expand Up @@ -87,7 +88,8 @@ def send_audio(self, audio_file: str, lang: str = "en-us",
audio_file = self.convert_audio(audio_file)
self._send_audio(audio_file, lang, username, user_profiles)

def convert_audio(self, audio_file: str, target_sr=16000, target_channels=1, dtype='int16') -> str:
def convert_audio(self, audio_file: str, target_sr=16000, target_channels=1,
dtype='int16') -> str:
"""
@param audio_file: path to audio file to convert for speech model
@returns: path to converted audio file
Expand All @@ -101,9 +103,9 @@ def convert_audio(self, audio_file: str, target_sr=16000, target_channels=1, dty

# Resample the audio to the target sample rate
y_resampled = librosa.resample(y, orig_sr=sr, target_sr=target_sr)

# Ensure the audio array is in the correct format (int16 for 2-byte samples)
y_resampled = (y_resampled * (2**(8*2 - 1))).astype(dtype)
y_resampled = (y_resampled * (2 ** (8 * 2 - 1))).astype(dtype)

output_path = join(join(xdg_data_home(), "iris", "stt"), f"{time()}.wav")
# Save the audio file with the new sample rate and sample width
Expand Down Expand Up @@ -142,27 +144,29 @@ def run(self):
"""
title = self.config.get("webui_title", "Neon AI")
description = self.config.get("webui_description", "Chat With Neon")
chatbot = self.config.get("webui_chatbot_label") or description
speech = self.config.get("webui_mic_label") or description
placeholder = self.config.get("webui_input_placeholder",
"Ask me something")
address = self.config.get("server_address") or "0.0.0.0"
port = self.config.get("server_port") or 7860

chatbot = gradio.Chatbot(label=description)
chatbot = gradio.Chatbot(label=chatbot)
textbox = gradio.Textbox(placeholder=placeholder)

with self.chat_ui as blocks:
# Define primary UI
audio_input = gradio.Audio(source="microphone",
type="filepath",
label="Talk to NEON",
auto_submit=True)
type="filepath",
label=speech,
auto_submit=True)
gradio.ChatInterface(self.on_user_input,
chatbot=chatbot,
textbox=textbox,
additional_inputs=[audio_input],
title=title,
retry_btn=None,
undo_btn=None,)
undo_btn=None, )
tts_audio = gradio.Audio(autoplay=True, visible=True,
label="Neon's Response")
tts_button = gradio.Button("Play TTS")
Expand Down
5 changes: 2 additions & 3 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
click~=8.0
click-default-group~=1.2
neon-utils~=1.0
neon-utils[audio]~=1.0
pyyaml>=5.4,<7.0.0
neon-mq-connector~=0.7,>=0.7.1a4
ovos-bus-client~=0.0.3
librosa~=0.10.1
ovos-bus-client~=0.0.3

0 comments on commit ec12067

Please sign in to comment.