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 ...@@ -4,6 +4,7 @@ import wave
import sys import sys
import struct import struct
def read(file_name): def read(file_name):
signal = numpy.fromfile(file_name, dtype=numpy.int16) signal = numpy.fromfile(file_name, dtype=numpy.int16)
return signal return signal
...@@ -12,19 +13,18 @@ def read(file_name): ...@@ -12,19 +13,18 @@ def read(file_name):
signal = read(sys.argv[1]) signal = read(sys.argv[1])
sampleRate = 128.0 # hertz sampleRate = 128.0 # hertz
duration = len(signal) / sampleRate # seconds duration = len(signal) / sampleRate # seconds
wavef = wave.open('out.wav','w') wavef = wave.open("out.wav", "w")
wavef.setnchannels(1) # mono wavef.setnchannels(1) # mono
wavef.setsampwidth(2) wavef.setsampwidth(2)
wavef.setframerate(sampleRate) wavef.setframerate(sampleRate)
for i in range(int(duration * sampleRate)): for i in range(int(duration * sampleRate)):
value = int(signal[i]) value = int(signal[i])
data = struct.pack('<h', value) data = struct.pack("<h", value)
wavef.writeframesraw( data ) wavef.writeframesraw(data)
wavef.close() 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