Skip to content
Snippets Groups Projects
Commit 6015af16 authored by rahix's avatar rahix
Browse files

chore(ecg2wav): Apply code-style

parent 0ede5c64
No related branches found
No related tags found
No related merge requests found
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment