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
055333c4
Commit
055333c4
authored
7 months ago
by
Eustache Le Bihan
Browse files
Options
Downloads
Patches
Plain Diff
clean code
parent
ec1ee52e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
s2s_pipeline.py
+8
-2
8 additions, 2 deletions
s2s_pipeline.py
with
8 additions
and
2 deletions
s2s_pipeline.py
+
8
−
2
View file @
055333c4
...
@@ -13,6 +13,7 @@ from time import perf_counter
...
@@ -13,6 +13,7 @@ from time import perf_counter
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
import
nltk
from
nltk.tokenize
import
sent_tokenize
from
nltk.tokenize
import
sent_tokenize
from
rich.console
import
Console
from
rich.console
import
Console
from
transformers
import
(
from
transformers
import
(
...
@@ -36,6 +37,11 @@ from utils import (
...
@@ -36,6 +37,11 @@ from utils import (
next_power_of_2
next_power_of_2
)
)
# Ensure that the necessary NLTK resources are available
try
:
nltk
.
data
.
find
(
'
tokenizers/punkt_tab
'
)
except
LookupError
:
nltk
.
download
(
'
punkt_tab
'
)
# caching allows ~50% compilation time reduction
# caching allows ~50% compilation time reduction
# see https://docs.google.com/document/d/1y5CRfMLdwEoF1nTk9q8qEu1mgMUuUtvhklPKJ2emLU8/edit#heading=h.o2asbxsrp1ma
# see https://docs.google.com/document/d/1y5CRfMLdwEoF1nTk9q8qEu1mgMUuUtvhklPKJ2emLU8/edit#heading=h.o2asbxsrp1ma
...
@@ -337,9 +343,9 @@ class VADHandler(BaseHandler):
...
@@ -337,9 +343,9 @@ class VADHandler(BaseHandler):
array
=
torch
.
cat
(
vad_output
).
cpu
().
numpy
()
array
=
torch
.
cat
(
vad_output
).
cpu
().
numpy
()
duration_ms
=
len
(
array
)
/
self
.
sample_rate
*
1000
duration_ms
=
len
(
array
)
/
self
.
sample_rate
*
1000
if
duration_ms
<
self
.
min_speech_ms
or
duration_ms
>
self
.
max_speech_ms
:
if
duration_ms
<
self
.
min_speech_ms
or
duration_ms
>
self
.
max_speech_ms
:
logger
.
debug
(
f
"
audio input of duration:
{
len
(
array
)
/
self
.
_
sample_rate
}
s, skipping
"
)
logger
.
debug
(
f
"
audio input of duration:
{
len
(
array
)
/
self
.
sample_rate
}
s, skipping
"
)
else
:
else
:
self
.
_
should_listen
.
clear
()
self
.
should_listen
.
clear
()
logger
.
debug
(
"
Stop listening
"
)
logger
.
debug
(
"
Stop listening
"
)
yield
array
yield
array
...
...
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