Exemplo n.º 1
0
def GetFeedbackOnSong(profileKey, elementDict, writer):
    # should get feedback on the three tracks in context of the song
    writer.PrintAndWrite("** Feedback on song ** ", False)

    for i in range(0, 3):

        currentInstruments = []

        for j in elementDict:
            current = elementDict[j].getElements()[i]
            currentInstruments.append(current)

        if int(i) == 0:
            writer.PrintAndWrite(
                "Rate the GUITAR track from the generated song ",
                onlyWrite=False)
        elif i == 1:
            writer.PrintAndWrite(
                "Rate the BASS track from the generated song ", False)
        elif i == 2:
            writer.PrintAndWrite(
                "Rate the DRUM track from the generated song ", False)

        feedbackGuitar = GetFeedback(writer)
        normalizedRating = Normalizer.normalizeRating(feedbackGuitar)
        QueryRunner.InsertUserPreferenceFromSlice(profileKey,
                                                  currentInstruments,
                                                  normalizedRating)
Exemplo n.º 2
0
def GetFeedbackForKNumberOfSlices(profileKey,
                                  elementDictionary,
                                  writer,
                                  numRandom=3):
    writer.PrintAndWrite("", False)
    writer.PrintAndWrite("** SLICE FEEDBACK ** ", False)

    ratedList = []

    elementDicKeyList = list(elementDictionary.keys())

    loop = 0

    if len(elementDicKeyList) < numRandom:
        loop = len(elementDicKeyList)
    else:
        loop = numRandom

    for i in range(0, loop):

        randomKey = random.choice(elementDicKeyList)

        while randomKey in ratedList:
            randomKey = random.choice(elementDicKeyList)

        ratedList.append(randomKey)

        sliceIdList = elementDictionary[randomKey].getElements()

        success = FeedbackFileCreator.CreateSliceAudioFileForEvaluation(
            sliceIdList)
        if success is False:
            writer.PrintAndWrite(
                "something went wrong with creating the audio file for evaluation"
            )
            continue

        writer.PrintAndWrite("")
        writer.PrintAndWrite("slice id: " + str(sliceIdList), False)
        writer.PrintAndWrite(
            "Listen to the clips and come back. I'll be waiting :) ")

        feedback = GetFeedback(writer)
        normalizedRating = Normalizer.normalizeRating(feedback)

        QueryRunner.InsertUserPreferenceFromSlice(profileKey, sliceIdList,
                                                  normalizedRating)

    writer.PrintAndWrite("Slice Feedback done", False)
    writer.PrintAndWrite("")