mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
move client files
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -165,7 +165,7 @@ cython_debug/
|
|||||||
transcript_*.txt
|
transcript_*.txt
|
||||||
test_*.txt
|
test_*.txt
|
||||||
wordcloud*.png
|
wordcloud*.png
|
||||||
*.ini
|
utils/config.ini
|
||||||
test_samples/
|
test_samples/
|
||||||
*.wav
|
*.wav
|
||||||
*.mp3
|
*.mp3
|
||||||
|
|||||||
6
client-local/__init__.py
Normal file
6
client-local/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
|
os.pardir))
|
||||||
|
sys.path.append(parent_dir)
|
||||||
@@ -5,15 +5,15 @@ import signal
|
|||||||
from aiortc.contrib.signaling import (add_signaling_arguments,
|
from aiortc.contrib.signaling import (add_signaling_arguments,
|
||||||
create_signaling)
|
create_signaling)
|
||||||
|
|
||||||
|
from ..utils.log_utils import logger
|
||||||
from stream_client import StreamClient
|
from stream_client import StreamClient
|
||||||
from utils.log_utils import logger
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
parser = argparse.ArgumentParser(description="Data channels ping/pong")
|
parser = argparse.ArgumentParser(description="Data channels ping/pong")
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--url", type=str, nargs="?", default="http://127.0.0.1:1250/offer"
|
"--url", type=str, nargs="?", default="http://0.0.0.0:1250/offer"
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -9,15 +9,15 @@ import stamina
|
|||||||
from aiortc import (RTCPeerConnection, RTCSessionDescription)
|
from aiortc import (RTCPeerConnection, RTCSessionDescription)
|
||||||
from aiortc.contrib.media import (MediaPlayer, MediaRelay)
|
from aiortc.contrib.media import (MediaPlayer, MediaRelay)
|
||||||
|
|
||||||
from utils.log_utils import logger
|
from ..utils.log_utils import logger
|
||||||
from utils.run_utils import config
|
from ..utils.run_utils import config
|
||||||
|
|
||||||
|
|
||||||
class StreamClient:
|
class StreamClient:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
signaling,
|
signaling,
|
||||||
url="http://127.0.0.1:1250",
|
url="http://0.0.0.0:1250",
|
||||||
play_from=None,
|
play_from=None,
|
||||||
ping_pong=False
|
ping_pong=False
|
||||||
):
|
):
|
||||||
21
server.py
21
server.py
@@ -1,3 +1,4 @@
|
|||||||
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
@@ -16,7 +17,7 @@ from faster_whisper import WhisperModel
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from sortedcontainers import SortedDict
|
from sortedcontainers import SortedDict
|
||||||
|
|
||||||
from utils.run_utils import run_in_executor
|
from utils.run_utils import run_in_executor, config
|
||||||
|
|
||||||
pcs = set()
|
pcs = set()
|
||||||
relay = MediaRelay()
|
relay = MediaRelay()
|
||||||
@@ -31,8 +32,8 @@ audio_buffer = AudioFifo()
|
|||||||
executor = ThreadPoolExecutor()
|
executor = ThreadPoolExecutor()
|
||||||
transcription_text = ""
|
transcription_text = ""
|
||||||
last_transcribed_time = 0.0
|
last_transcribed_time = 0.0
|
||||||
LLM_MACHINE_IP = "216.153.52.83"
|
LLM_MACHINE_IP = config["DEFAULT"]["LLM_MACHINE_IP"]
|
||||||
LLM_MACHINE_PORT = "5000"
|
LLM_MACHINE_PORT = config["DEFAULT"]["LLM_MACHINE_PORT"]
|
||||||
LLM_URL = f"http://{LLM_MACHINE_IP}:{LLM_MACHINE_PORT}/api/v1/generate"
|
LLM_URL = f"http://{LLM_MACHINE_IP}:{LLM_MACHINE_PORT}/api/v1/generate"
|
||||||
incremental_responses = []
|
incremental_responses = []
|
||||||
sorted_transcripts = SortedDict()
|
sorted_transcripts = SortedDict()
|
||||||
@@ -43,7 +44,7 @@ blacklisted_messages = [" Thank you.", " See you next time!",
|
|||||||
|
|
||||||
|
|
||||||
def get_title_and_summary(llm_input_text, last_timestamp):
|
def get_title_and_summary(llm_input_text, last_timestamp):
|
||||||
("Generating title and summary")
|
logger.info("Generating title and summary")
|
||||||
# output = llm.generate(prompt)
|
# output = llm.generate(prompt)
|
||||||
|
|
||||||
# Use monadical-ml to fire this query to an LLM and get result
|
# Use monadical-ml to fire this query to an LLM and get result
|
||||||
@@ -306,6 +307,16 @@ async def on_shutdown(app):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="WebRTC based server for Reflector"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--host", default="0.0.0.0", help="Server host IP (def: 0.0.0.0)"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--port", type=int, default=1250, help="Server port (def: 1250)"
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
cors = aiohttp_cors.setup(
|
cors = aiohttp_cors.setup(
|
||||||
app,
|
app,
|
||||||
@@ -321,4 +332,4 @@ if __name__ == "__main__":
|
|||||||
offer_resource = cors.add(app.router.add_resource("/offer"))
|
offer_resource = cors.add(app.router.add_resource("/offer"))
|
||||||
cors.add(offer_resource.add_route("POST", offer))
|
cors.add(offer_resource.add_route("POST", offer))
|
||||||
app.on_shutdown.append(on_shutdown)
|
app.on_shutdown.append(on_shutdown)
|
||||||
web.run_app(app, access_log=None, host="127.0.0.1", port=1250)
|
web.run_app(app, access_log=None, host=args.host, port=args.port)
|
||||||
|
|||||||
Reference in New Issue
Block a user