Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
6015af16
Commit
6015af16
authored
Dec 29, 2019
by
Rahix
Browse files
chore(ecg2wav): Apply code-style
parent
0ede5c64
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/ecg2wav.py
View file @
6015af16
...
...
@@ -4,6 +4,7 @@ import wave
import
sys
import
struct
def
read
(
file_name
):
signal
=
numpy
.
fromfile
(
file_name
,
dtype
=
numpy
.
int16
)
return
signal
...
...
@@ -12,19 +13,18 @@ def read(file_name):
signal
=
read
(
sys
.
argv
[
1
])
sampleRate
=
128.0
# hertz
duration
=
len
(
signal
)
/
sampleRate
# seconds
sampleRate
=
128.0
# hertz
duration
=
len
(
signal
)
/
sampleRate
# seconds
wavef
=
wave
.
open
(
'
out.wav
'
,
'w'
)
wavef
.
setnchannels
(
1
)
# mono
wavef
.
setsampwidth
(
2
)
wavef
=
wave
.
open
(
"
out.wav
"
,
"w"
)
wavef
.
setnchannels
(
1
)
# mono
wavef
.
setsampwidth
(
2
)
wavef
.
setframerate
(
sampleRate
)
for
i
in
range
(
int
(
duration
*
sampleRate
)):
value
=
int
(
signal
[
i
])
data
=
struct
.
pack
(
'
<h
'
,
value
)
wavef
.
writeframesraw
(
data
)
data
=
struct
.
pack
(
"
<h
"
,
value
)
wavef
.
writeframesraw
(
data
)
wavef
.
close
()
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