Skip to content

Commit

Permalink
further changes to fix altlabel
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Nov 18, 2024
1 parent dc06955 commit 682e08b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
21 changes: 20 additions & 1 deletion src/morphodict/paradigm/recordings.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
20 changes: 0 additions & 20 deletions src/morphodict/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand Down

0 comments on commit 682e08b

Please sign in to comment.