Skip to content

Commit

Permalink
Import print function from future
Browse files Browse the repository at this point in the history
This commit changes print to the version used in python3 and
keeps backwards compatibbility with python2 by importing
from future.
  • Loading branch information
felixdollack committed Mar 16, 2019
1 parent 603401d commit cc3a29f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 8 additions & 7 deletions acquire_data/say_numbers_prompt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import print_function
import time
import math

"""
Prompts you to say numbers.
Prompts you to say numbers.
Start this, and then hit "Record" in Audacity.
Start this, and then hit "Record" in Audacity.
http://www.audacityteam.org/download/
When you start Audacity, look in the bottom-left and set the Project Rate (Hz) to 8000.
Expand All @@ -15,7 +16,7 @@
- Try a short recording session first to make sure everything works OK before doing the full recording.
When done, export the audio as one big .wav file and use 'split_and_label_numbers.py'
When done, export the audio as one big .wav file and use 'split_and_label_numbers.py'
to make the labeled dataset.
"""

Expand Down Expand Up @@ -43,22 +44,22 @@ def generate_number_sequence():
def show_numbers():
nums = generate_number_sequence()

print "Get ready..."
print("Get ready...")
time.sleep(1)

t_start = time.time()
for i, num in enumerate(nums):
if (float(i)/len(nums) * 100) % 10 == 0:
print "\n====", float(i)/len(nums)*100, "% done====\n"
print("\n====", float(i)/len(nums)*100, "% done====\n")
else:
print ""
print("")

t_next_display = t_start + (i + 1) * DELAY_BETWEEN_NUMBERS
t_next_blank = t_next_display + 2.5

# display a number
wait_until(t_next_display)
print num
print(num)

# blank
wait_until(t_next_blank)
Expand Down
3 changes: 2 additions & 1 deletion utils/fsdd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
from collections import defaultdict
import scipy.io.wavfile
Expand Down Expand Up @@ -47,7 +48,7 @@ def get_spectrograms(data_dir=None):

if data_dir is None:
data_dir = os.path.dirname(__file__) + '/../spectrograms'
print data_dir
print(data_dir)

file_paths = [f for f in os.listdir(data_dir) if os.path.isfile(os.path.join(data_dir, f)) and '.png' in f]

Expand Down
4 changes: 2 additions & 2 deletions utils/spectogramer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import division
from __future__ import division, print_function
from os import listdir
from os.path import isfile, join
from wand.image import Image
Expand Down Expand Up @@ -48,7 +48,7 @@ def dir_to_spectrogram(audio_dir, spectrogram_dir, spectrogram_dimensions=(64, 6
file_names = [f for f in listdir(audio_dir) if isfile(join(audio_dir, f)) and '.wav' in f]

for file_name in file_names:
print file_name
print(file_name)
audio_path = audio_dir + file_name
spectogram_path = spectrogram_dir + file_name.replace('.wav', '.png')
wav_to_spectrogram(audio_path, spectogram_path, spectrogram_dimensions=spectrogram_dimensions, noverlap=noverlap, cmap=cmap)
Expand Down

0 comments on commit cc3a29f

Please sign in to comment.