示例#1
0
def main(argv):
    # db = AudioDB()  # This should only be run once
    # db.setup()  # This should only be run once

    cfg = load_config()

    type = ""

    try:
        opts, _ = getopt.getopt(argv, "ht:", ["help", "type="])
    except getopt.GetoptError:
        print('__main__.py -t <api_type>')
        sys.exit(2)
    for opt, arg in opts:
        if opt in ('-h', "help"):
            print('__main__.py -t <api_type>')
            sys.exit()
        elif opt in ('-t', "--type"):
            type = arg

    if type in ("general", ""):
        g_app.run(host=cfg['rest_api_host_url'],
                  port=cfg['rest_api_host_port'], debug=cfg['rest_api_debug'])
    elif type == "music":
        m_app.run(host=cfg['rest_api_host_url'],
                  port=cfg['rest_api_host_port'], debug=cfg['rest_api_debug'])
    elif type == "video":
        v_app.run(host=cfg['rest_api_host_url'],
                  port=cfg['rest_api_host_port'], debug=cfg['rest_api_debug'])
示例#2
0
    def __init__(self):
        cfg = load_config()

        self._client = MongoClient(cfg['mongo_host'],
                                   cfg['mongo_port'],
                                   username=cfg['mongo_user'],
                                   password=cfg['mongo_pass'])
        self._db = self._client[cfg['mongo_db']]
示例#3
0
import numpy as np
import falconn

from database.mongo.audio.song_segment import SongSegment
from similarity.similarity import _load_songs, _dist, \
    _create_bucket, _find_matches
from utilities.config_loader import load_config

cfg = load_config()
MATCHES = cfg['similarity_matches']


def test_load_songs(mocker):
    mock_get = mocker.patch.object(SongSegment, 'get_all_by_song_id', autospec=True, return_value=[])
    mock_add = mocker.patch.object(SongSegment, 'add', autospec=True)

    segments = _load_songs(
        [('8376-1-1', "similarity/t/test_split_song" +
          "/8376-1-1_Demolition_Man_" +
          "proud_music_preview.wav")])

    mock_get.assert_called_once()
    mock_add.assert_called()

    assert len(segments) == 18
    assert segments[0][1] == '8376-1-1'
    assert segments[0][2] == 0


def test_create_bucket(mocker):
    mock_get = mocker.patch.object(SongSegment, 'get_all_by_song_id', autospec=True, return_value=[])
示例#4
0
    def __init__(self):
        cfg = load_config()

        self._db = Database("{}://{}:{}@{}/{}".format(
            cfg['sql_type'], cfg['sql_user'], cfg['sql_pass'],
            cfg['sql_host'], cfg['sql_db']))