diff --git a/src/morphodict/paradigm/recordings.py b/src/morphodict/paradigm/recordings.py index 087b49ddf..169464796 100644 --- a/src/morphodict/paradigm/recordings.py +++ b/src/morphodict/paradigm/recordings.py @@ -1,5 +1,24 @@ -from morphodict.utils import get_recordings_from_url from morphodict.paradigm.panes import WordformCell +from morphodict.utils import macron_to_circumflex +import requests +import urllib + +def get_recordings_from_url(search_terms, url, speech_db_eq): + matched_recordings = {} + query_params = [("q", term) for term in search_terms] + response = requests.get(url + "?" + urllib.parse.urlencode(query_params)) + recordings = response.json() + + for recording in recordings["matched_recordings"]: + if "moswacihk" in speech_db_eq: + entry = macron_to_circumflex(recording["wordform"]) + else: + entry = recording["wordform"] + matched_recordings[entry] = {} + matched_recordings[entry]["recording_url"] = recording["recording_url"] + matched_recordings[entry]["speaker"] = recording["speaker"] + + return matched_recordings def get_recordings_from_paradigm( diff --git a/src/morphodict/utils/__init__.py b/src/morphodict/utils/__init__.py index afe318dd2..2c1dc17b1 100644 --- a/src/morphodict/utils/__init__.py +++ b/src/morphodict/utils/__init__.py @@ -1,26 +1,6 @@ from .cree_lev_dist import get_modified_distance # Unused but exported from .shared_res_dir import shared_res_dir # Unused but exported -import requests -import urllib - -def get_recordings_from_url(search_terms, url, speech_db_eq): - matched_recordings = {} - query_params = [("q", term) for term in search_terms] - response = requests.get(url + "?" + urllib.parse.urlencode(query_params)) - recordings = response.json() - - for recording in recordings["matched_recordings"]: - if "moswacihk" in speech_db_eq: - entry = macron_to_circumflex(recording["wordform"]) - else: - entry = recording["wordform"] - matched_recordings[entry] = {} - matched_recordings[entry]["recording_url"] = recording["recording_url"] - matched_recordings[entry]["speaker"] = recording["speaker"] - - return matched_recordings - def macron_to_circumflex(item): """