Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Speech To Speech
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
huggingface
Speech To Speech
Commits
011d2550
Commit
011d2550
authored
7 months ago
by
Eustache Le Bihan
Browse files
Options
Downloads
Patches
Plain Diff
handle local run
parent
46f3eae2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
listen_and_play.py
+9
-9
9 additions, 9 deletions
listen_and_play.py
s2s_pipeline.py
+8
-6
8 additions, 6 deletions
s2s_pipeline.py
with
17 additions
and
15 deletions
listen_and_play.py
+
9
−
9
View file @
011d2550
...
...
@@ -3,6 +3,7 @@ import numpy as np
import
threading
from
queue
import
Queue
from
dataclasses
import
dataclass
,
field
import
sounddevice
as
sd
from
transformers
import
HfArgumentParser
...
...
@@ -26,19 +27,19 @@ class ListenAndPlayArguments:
"
help
"
:
"
The size of data chunks (in bytes). Default is 1024.
"
}
)
listen_play_
host
:
str
=
field
(
host
:
str
=
field
(
default
=
"
localhost
"
,
metadata
=
{
"
help
"
:
"
The hostname or IP address for listening and playing. Default is
'
localhost
'
.
"
}
)
listen_play_
send_port
:
int
=
field
(
send_port
:
int
=
field
(
default
=
12345
,
metadata
=
{
"
help
"
:
"
The network port for sending data. Default is 12345.
"
}
)
listen_play_
recv_port
:
int
=
field
(
recv_port
:
int
=
field
(
default
=
12346
,
metadata
=
{
"
help
"
:
"
The network port for receiving data. Default is 12346.
"
...
...
@@ -50,17 +51,16 @@ def listen_and_play(
send_rate
=
16000
,
recv_rate
=
44100
,
list_play_chunk_size
=
1024
,
listen_play_
host
=
"
localhost
"
,
listen_play_
send_port
=
12345
,
listen_play_
recv_port
=
12346
,
host
=
"
localhost
"
,
send_port
=
12345
,
recv_port
=
12346
,
):
import
sounddevice
as
sd
send_socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
send_socket
.
connect
((
listen_play_host
,
listen_play_
send_port
))
send_socket
.
connect
((
host
,
send_port
))
recv_socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
recv_socket
.
connect
((
listen_play_host
,
listen_play_
recv_port
))
recv_socket
.
connect
((
host
,
recv_port
))
print
(
"
Recording and streaming...
"
)
...
...
This diff is collapsed.
Click to expand it.
s2s_pipeline.py
+
8
−
6
View file @
011d2550
...
...
@@ -34,11 +34,10 @@ from utils import (
int2float
,
)
from
listen_and_play
import
ListenAndPlayArguments
console
=
Console
()
@dataclass
class
ModuleArguments
:
log_level
:
str
=
field
(
...
...
@@ -647,7 +646,6 @@ def main():
WhisperSTTHandlerArguments
,
LanguageModelHandlerArguments
,
ParlerTTSHandlerArguments
,
ListenAndPlayArguments
))
# 0. Parse CLI arguments
...
...
@@ -661,7 +659,6 @@ def main():
whisper_stt_handler_kwargs
,
language_model_handler_kwargs
,
parler_tts_handler_kwargs
,
listen_and_play_kwargs
,
)
=
parser
.
parse_json_file
(
json_file
=
os
.
path
.
abspath
(
sys
.
argv
[
1
]))
else
:
# Parse arguments from command line if no JSON file is provided
...
...
@@ -673,7 +670,6 @@ def main():
whisper_stt_handler_kwargs
,
language_model_handler_kwargs
,
parler_tts_handler_kwargs
,
listen_and_play_kwargs
)
=
parser
.
parse_args_into_dataclasses
()
global
logger
...
...
@@ -753,10 +749,16 @@ def main():
if
module_kwargs
.
client
:
from
listen_and_play
import
listen_and_play
kwargs
=
{
"
host
"
:
"
localhost
"
,
"
send_port
"
:
socket_sender_kwargs
.
send_port
,
"
recv_port
"
:
socket_receiver_kwargs
.
recv_port
,
}
listen_and_play_process
=
multiprocessing
.
Process
(
target
=
listen_and_play
,
kwargs
=
vars
(
listen_and_play_
kwargs
)
,
kwargs
=
kwargs
,
)
listen_and_play_process
.
start
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment