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
card10
firmware
Commits
0ede5c64
Commit
0ede5c64
authored
Dec 29, 2019
by
G
Browse files
ecg2wav.py, converts ecg log files to wav files
parent
eed9ffda
Pipeline
#4416
passed with stages
in 1 minute and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tools/ecg2wav.py
0 → 100644
View file @
0ede5c64
# vim: set ts=4 sw=4 tw=0 et pm=:
import
numpy
import
wave
import
sys
import
struct
def
read
(
file_name
):
signal
=
numpy
.
fromfile
(
file_name
,
dtype
=
numpy
.
int16
)
return
signal
signal
=
read
(
sys
.
argv
[
1
])
sampleRate
=
128.0
# hertz
duration
=
len
(
signal
)
/
sampleRate
# seconds
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
)
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