Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
8ffbef7f
Commit
8ffbef7f
authored
May 19, 2022
by
Jean-Baptiste Mardelle
Browse files
Fix speech to text on Mac
parent
b128c3b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
data/scripts/speech.py
View file @
8ffbef7f
...
...
@@ -20,12 +20,18 @@ if not os.path.exists(sys.argv[2]):
print
(
"Please download the model from https://alphacephei.com/vosk/models and unpack as "
,
sys
.
argv
[
2
],
" in the current folder."
)
exit
(
1
)
if
sys
.
platform
==
'darwin'
:
from
os.path
import
abspath
,
dirname
,
join
path
=
abspath
(
join
(
dirname
(
__file__
),
'../../MacOS/ffmpeg'
))
else
:
path
=
'ffmpeg'
sample_rate
=
16000
model
=
Model
(
sys
.
argv
[
2
])
rec
=
KaldiRecognizer
(
model
,
sample_rate
)
rec
.
SetWords
(
True
)
process
=
subprocess
.
Popen
([
'ffmpeg'
,
'-loglevel'
,
'quiet'
,
'-i'
,
process
=
subprocess
.
Popen
([
path
,
'-loglevel'
,
'quiet'
,
'-i'
,
sys
.
argv
[
3
],
'-ar'
,
str
(
sample_rate
)
,
'-ac'
,
'1'
,
'-f'
,
's16le'
,
'-'
],
stdout
=
subprocess
.
PIPE
)
...
...
data/scripts/speechtotext.py
View file @
8ffbef7f
...
...
@@ -19,6 +19,12 @@ if not os.path.exists(sys.argv[2]):
print
(
"Please download the model from https://alphacephei.com/vosk/models and unpack as "
,
sys
.
argv
[
2
],
" in the current folder."
)
exit
(
1
)
if
sys
.
platform
==
'darwin'
:
from
os.path
import
abspath
,
dirname
,
join
path
=
abspath
(
join
(
dirname
(
__file__
),
'../../MacOS/ffmpeg'
))
else
:
path
=
'ffmpeg'
sample_rate
=
16000
model
=
Model
(
sys
.
argv
[
2
])
rec
=
KaldiRecognizer
(
model
,
sample_rate
)
...
...
@@ -26,12 +32,12 @@ rec.SetWords(True)
# zone rendering
if
len
(
sys
.
argv
)
>
4
and
(
float
(
sys
.
argv
[
4
])
>
0
or
float
(
sys
.
argv
[
5
])
>
0
):
process
=
subprocess
.
Popen
([
'ffmpeg'
,
'-loglevel'
,
'quiet'
,
'-i'
,
process
=
subprocess
.
Popen
([
path
,
'-loglevel'
,
'quiet'
,
'-i'
,
sys
.
argv
[
3
],
'-ss'
,
sys
.
argv
[
4
],
'-t'
,
sys
.
argv
[
5
],
'-ar'
,
str
(
sample_rate
)
,
'-ac'
,
'1'
,
'-f'
,
's16le'
,
'-'
],
stdout
=
subprocess
.
PIPE
)
else
:
process
=
subprocess
.
Popen
([
'ffmpeg'
,
'-loglevel'
,
'quiet'
,
'-i'
,
process
=
subprocess
.
Popen
([
path
,
'-loglevel'
,
'quiet'
,
'-i'
,
sys
.
argv
[
3
],
'-ar'
,
str
(
sample_rate
)
,
'-ac'
,
'1'
,
'-f'
,
's16le'
,
'-'
],
stdout
=
subprocess
.
PIPE
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment