Commit 6015af16 authored by Rahix's avatar Rahix
Browse files

chore(ecg2wav): Apply code-style

parent 0ede5c64
......@@ -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()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment