Пример #1
0
class AnnotatedLevelSentenceSpeech(serializers.ModelSerializer):

    audio = core_serializer.AudioDataSerializer()
    level_sentence = LevelSentenceText()

    class Meta:
        model = models.LevelSentenceSpeech
        fields = (
            'id',
            'audio',
            'level_sentence',
        )
Пример #2
0
class AnnotatedIsolatedWordSpeech(serializers.ModelSerializer):

    audio = core_serializer.AudioDataSerializer()
    isolated_word = IsolatedWordText()

    class Meta:
        model = models.IsolatedWordSpeech
        fields = (
            'id',
            'audio',
            'isolated_word',
        )
Пример #3
0
class AnnotatedTaleSentenceSpeech(ModelSerializer):

    audio = core_serializers.AudioDataSerializer()
    tale_sentence = TaleSentenceSerializer()

    class Meta:
        model = tales_models.SentenceTaleSpeech
        fields = (
            'id',
            'audio',
            'tale_sentence',
        )
Пример #4
0
    def get(self, request, format=None):
        offset = request.query_params.get('offset', 50)
        sentence_tales = tales_models.SentenceTaleSpeech.objects.values(
            'tale_sentence').annotate(count=models.Count(
                'tale_sentence')).order_by('-count')[:offset]

        audio_datas = []
        print(sentence_tales)
        for s in sentence_tales:
            speech_tales = tales_models.SentenceTaleSpeech.objects.filter(
                tale_sentence__id=s['tale_sentence'])
            for a in speech_tales:
                audio_datas.append(a.audio)

        serializer = core_serializers.AudioDataSerializer(audio_datas,
                                                          many=True)
        return Response(serializer.data)
Пример #5
0
 def post(self, request, format=None):
     print(request.data)
     audio_serializer = core_serializers.AudioDataSerializer(
         data=request.data)
     if audio_serializer.is_valid(True):
         audio_data = audio_serializer.save()
         print(audio_data)
         anonymous_user_id = request.data.get('anonymous_user', None)
         if anonymous_user_id is not None:
             try:
                 anonymous_user = authentication_models.AnonymousUserProfile.objects.get(
                     pk=anonymous_user_id)
                 anonymous_audio_data = core_models.AnonymousAudioData(
                     audio=audio_data, user=anonymous_user)
                 anonymous_audio_data.save()
             except authentication_models.AnonymousUserProfile.DoesNotExist:
                 return Response({
                     'state': 'Anonimous User not defined',
                     'error': 0
                 })
         return Response({'state': 'Success', 'error': 0})
     else:
         return Response({'state': 'Incomplete', 'error': 1})
Пример #6
0
class AnonymousUserCustomAudioSerializer(serializers.Serializer):
    anonymous_user = serializers.IntegerField()
    audio = core_serializer.AudioDataSerializer()