-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackend.yaml
2024 lines (2006 loc) · 65.5 KB
/
backend.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: Quizzr.io Data Flow Server
version: 0.13.2
summary: API for the Flask data flow server
description: 'The Quizzr.io data flow server functions as the central piece of the back-end, handling requests for changing and getting data in common but specific manners. Examples include pre-screening audio recordings of question transcripts, selecting a question to answer or record, and enabling asynchronous processing of audio. It is written in the Flask framework for Python 3.8 and uses Firebase Storage to store audio files and the MongoDB Quizzr Atlas to store data. It is especially designed to work with the front-end portion of Quizzr.io. See the [browser-asr](https://github.com/UMD-Summer-2021-ASR/browser-asr) repository for more details on how to set it up with the back-end.'
contact:
name: Christopher Rapp
email: [email protected]
servers:
- url: 'http://localhost:5000'
- url: 'http://localhost:4455'
description: Proxy
- url: 'https://quizzr.stoplight.io'
description: Stoplight website
paths:
/answer:
get:
summary: Check an Answer
tags:
- frontend
- qb-pipeline
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
correct:
type: boolean
examples: {}
'400':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
operationId: check_answer
parameters:
- schema:
type: string
in: query
name: a
description: The answer to be checked
required: true
- schema:
type: string
in: query
name: qid
description: The ID of the question selected
required: true
description: Check if the user's answer approximately matches the stored answer of the associated question.
security:
- Firebase-Auth: []
'/answer_full/{qid}':
get:
summary: Get Answer
tags:
- internal
- qb-pipeline
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
answer:
type: string
required:
- answer
'400':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
operationId: get_answer
description: Retrieve an answer to a question.
parameters:
- schema:
type: integer
name: qid
in: path
required: true
description: The `qb_id` of a question
/audio:
get:
summary: Get Unprocessed Audio Batch
tags:
- internal
- rec-pipeline
responses:
'200':
description: Document Batch Found
content:
application/json:
schema:
description: ''
type: object
x-examples:
example-1:
results:
- _id: 1l77laMyEVIit3_AP7v_YQBxe9RQvJ4zT
transcript: The quick brown fox jumps over the lazy dog.
- _id: 1IirF6ac4p-_A7zyXuDWYIzWpNUUjKbt1
transcript: Hello world.
properties:
results:
type: array
uniqueItems: true
minItems: 1
items:
type: object
properties:
_id:
$ref: '#/components/schemas/Audio-Id'
transcript:
type: string
minLength: 1
diarMetadata:
type: string
required:
- _id
- transcript
errors:
$ref: '#/components/schemas/Errors'
required:
- results
examples:
example-1:
value:
results:
- _id: sFHPiWfpRae5C2-5v7tCjAvZzPDB5sr4w6WODxCZilo
transcript: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
- _id: C0cb6nKK5nQ8I12T4O4590hnnOPMm_Lxf7D9r7ZTrD4
transcript: Justo donec enim diam vulputate ut pharetra sit amet. Risus feugiat in ante metus dictum at. Faucibus et molestie ac feugiat sed. Eu mi bibendum neque egestas congue quisque egestas diam in. Et tortor at risus viverra adipiscing at in tellus integer. Leo duis ut diam quam nulla porttitor massa id neque. Euismod in pellentesque massa placerat duis ultricies lacus sed turpis.
'404':
$ref: '#/components/responses/Error'
operationId: get_unprocessed_audio
description: Retrieve a batch of unprocessed audio documents up to a limit specified by the `UNPROC_FIND_LIMIT` environment variable. Each audio document includes the ID of the audio document and the transcript (retrieved from the associated question document).
parameters: []
patch:
summary: Add Processed Audio Data
tags:
- internal
- rec-pipeline
responses:
'201':
description: Created
headers: {}
content:
application/json:
schema:
type: object
properties:
successes:
type: integer
total:
type: integer
errors:
$ref: '#/components/schemas/Errors'
required:
- successes
- total
'400':
$ref: '#/components/responses/Error'
operationId: handle_processing_results
requestBody:
content:
application/json:
schema:
type: object
properties:
arguments:
type: array
items:
type: object
properties:
_id:
$ref: '#/components/schemas/Audio-Id'
vtt:
$ref: '#/components/schemas/VTT'
score:
type: object
required:
- wer
- mer
- wil
properties:
wer:
type: number
description: Word Error Rate
mer:
type: number
description: Match Error Rate
wil:
type: number
description: Word Information Lost
batchNumber:
type: string
format: date
metadata:
type: string
required:
- _id
- vtt
- score
- batchNumber
- metadata
required:
- arguments
examples:
example-1:
value:
arguments:
- _id: aj1zL3A2Un3s23LJDA-tpeCnKQe0euXDsgWQVpzHjVg
vtt: |-
WEBVTT Kind: captions; Language: en
00:00:00.012345 --> 00:00:01.123456
<v Speaker 1>WORD1
00:00:01.123456 --> 00:00:02.123456
<v Speaker 1>WORD2
00:01:00.012345 --> 00:01:01.123456
<v Speaker 2>WORD3
00:01:01.123456 --> 00:01:02.123456
<v Speaker 2>WORD4
score:
wer: 1.124235
mer: 1
wil: 1
batchNumber: '2019-08-24'
metadata: 'detect_num_speakers=False, max_num_speakers=3'
description: A batch of results from processing audio files.
description: Update a batch of audio files with results from processing them.
parameters: []
post:
summary: Submit Recording
tags:
- frontend
- rec-pipeline
responses:
'202':
description: A list of tokens to get the status of each submission
content:
application/json:
schema:
type: object
properties:
prescreenPointers:
type: array
items:
$ref: '#/components/schemas/Prescreen-Pointer'
required:
- prescreenPointers
examples: {}
headers: {}
'400':
$ref: '#/components/responses/Error'
'500':
$ref: '#/components/responses/Error'
operationId: pre_screen
parameters: []
requestBody:
content:
multipart/form-data:
schema:
oneOf:
- properties:
audio:
type: string
format: binary
qb_id:
$ref: '#/components/schemas/QB-ID'
recType:
type: string
enum:
- normal
sentenceId:
type: integer
diarMetadata:
type: string
required:
- audio
- qb_id
- recType
- properties:
audio:
type: string
format: binary
recType:
type: string
enum:
- buzz
required:
- audio
- recType
- properties:
audio:
type: string
format: binary
recType:
type: string
enum:
- answer
expectedAnswer:
type: string
transcript:
type: string
description: The text decoded from the audio file
correct:
type: boolean
description: Whether the answer was correct
required:
- audio
- recType
- expectedAnswer
- transcript
- correct
type: object
encoding:
audio:
contentType: audio/wav
examples:
user-submission:
value:
audio: QBQuestionRec
qb_id: 1
recType: normal
admin-submission:
value:
audio: DiarizationTest
qb_id: 2
recType: normal
diarMetadata: 'detect_num_speakers=False, max_num_speakers=3'
user-buzz-submission:
value:
audio: BuzzRec
recType: buzz
description: The file to upload along with some transaction information.
description: Pre-screen the given audio file for how accurately it matches to the given question's transcript and upload it to the database if it is accurate enough.
security:
- Firebase-Auth: []
'/audio/{blob_path}':
parameters:
- $ref: '#/components/parameters/BlobPath'
get:
summary: Get Recording
tags:
- frontend
- qb-pipeline
responses:
'200':
description: Recording Found
content:
audio/wav:
schema:
type: string
format: binary
examples: {}
headers: {}
'404':
$ref: '#/components/responses/Error'
operationId: retrieve_audio_file
description: Retrieve an audio file from Firebase storage.
parameters: []
security:
- Firebase-Auth: []
/backend/key:
post:
summary: Generate Backend Key
tags:
- internal
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
key:
type: string
description: The secret key generated
required:
- key
'400':
$ref: '#/components/responses/Error'
'401':
$ref: '#/components/responses/Error'
operationId: generate_secret_key
description: |-
Generate a secret key to represent a given backend component.
**WARNING: A secret key can be generated only once per server session. This key cannot be recovered if lost.**
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: The name of the backend component to generate a key for
required:
- name
description: The arguments to provide in the POST request
'/downvote/{audio_id}':
parameters:
- schema:
type: string
name: audio_id
in: path
required: true
description: The target audio document ID
patch:
summary: Downvote a Recording
tags:
- frontend
- qb-pipeline
responses:
'200':
description: OK
'400':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
operationId: downvote
description: Downvote an audio recording
requestBody:
content:
application/json:
schema:
type: object
properties:
userId:
$ref: '#/components/schemas/User-Id'
/game:
post:
summary: Upload Game
tags:
- internal
- qb-pipeline
responses:
'201':
description: Created
'400':
$ref: '#/components/responses/Error'
operationId: post_game
description: Upload a game session to MongoDB.
requestBody:
content:
application/json:
schema:
type: object
properties:
id:
type: string
session:
$ref: '#/components/schemas/Game-Session'
required:
- id
- session
description: The game session to put into the collection along with the ID
'/game/{game_id}':
parameters:
- schema:
type: string
name: game_id
in: path
required: true
get:
summary: Get Game Session
tags:
- internal
- qb-pipeline
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Game-Session'
'400':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
description: Get a game session from MongoDB.
operationId: get_game
/game_results:
put:
summary: Send Game Session Results
tags:
- internal
- qb-pipeline
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
successful:
type: integer
description: The number of successful updates
requested:
type: integer
description: The number of users included in the request body
'400':
$ref: '#/components/responses/Error'
'401':
description: Unauthorized
operationId: handle_game_results
description: Update the database with the results of a game session.
requestBody:
content:
application/json:
schema:
oneOf:
- properties:
mode:
$ref: '#/components/schemas/Game-Mode'
category:
type: string
description: The subject category for this session
users:
type: object
required:
- <username>
properties:
<username>:
type: object
required:
- questionStats
- finished
- won
description: The update information for each `<username>`. Replace `<username>` with the name of the user you want to update.
properties:
questionStats:
type: object
required:
- played
- buzzed
- correct
- cumulativeProgressOnBuzz
properties:
played:
type: integer
description: The number of questions played
buzzed:
type: integer
description: The number of times the user buzzed in
correct:
type: integer
description: The number of times the user answered correctly
cumulativeProgressOnBuzz:
type: object
description: The cumulative amount of progress through the question when the player buzzes in.
required:
- percentQuestionRead
- numSentences
properties:
percentQuestionRead:
type: number
numSentences:
type: number
finished:
type: boolean
description: Whether the user finished playing this session
won:
type: boolean
description: ''
required:
- mode
- category
- users
- properties:
mode:
$ref: '#/components/schemas/Game-Mode'
categories:
type: array
description: The list of subject categories for this session
items:
type: string
users:
type: object
required:
- <username>
properties:
<username>:
type: object
required:
- questionStats
- finished
- won
description: The update information for each `<username>`. Replace `<username>` with the name of the user you want to update.
properties:
questionStats:
type: object
required:
- played
- buzzed
- correct
- cumulativeProgressOnBuzz
properties:
played:
type: object
required:
- <category>
description: The number of questions played for each category
properties:
<category>:
type: integer
buzzed:
type: object
required:
- <category>
description: The number of times the user buzzed in to answer a question of a particular category
properties:
<category>:
type: integer
correct:
type: object
required:
- <category>
description: The number of times the user correctly answered a question of a particular category
properties:
<category>:
type: integer
cumulativeProgressOnBuzz:
type: object
required:
- percentQuestionRead
- numSentences
description: 'The cumulative amount of progress through the question when the player buzzes in, per category'
properties:
percentQuestionRead:
type: object
required:
- <category>
properties:
<category>:
type: number
numSentences:
type: object
required:
- <category>
properties:
<category>:
type: number
finished:
type: boolean
description: Whether the user finished playing this session
won:
type: boolean
required:
- mode
- categories
- users
type: object
description: 'A document containing the results of the session, including the game mode, the categories, and the user profiles to update.'
parameters: []
security:
- Internal-Auth: []
parameters: []
'/hls/vtt/{audio_id}':
parameters:
- schema:
type: string
name: audio_id
in: path
required: true
description: The ID of an audio document
get:
summary: Get VTT
tags:
- internal
responses:
'200':
description: OK
content:
application/octet-stream:
schema:
$ref: '#/components/schemas/VTT'
'400':
$ref: '#/components/responses/Error'
'404':
description: Not Found
operationId: get_vtt
description: Get a VTT from an audio document
parameters:
- schema:
type: string
default: normal
enum:
- normal
- gentle
in: query
name: t
description: 'The type of VTT to get. Defaults to "normal", or the "vtt" field'
/leaderboard:
get:
summary: Get Leaderboard
tags:
- frontend
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
results:
type: array
items:
$ref: '#/components/schemas/Basic-Profile'
'400':
$ref: '#/components/responses/Error'
operationId: get_leaderboard
description: Get the leaderboard of users who participated in ranked games
parameters:
- schema:
type: string
in: query
name: category
description: The subject category to filter by
- schema:
type: integer
maximum: 200
in: query
name: size
description: Display the top `<size>` players
'/prescreen/{pointer}':
parameters:
- schema:
type: string
name: pointer
in: path
required: true
description: A short-lived pointer retrieved from /audio POST to get the status of a submission.
get:
summary: Get Submission Status
tags:
- frontend
- rec-pipeline
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- running
- finished
- err
name:
type: string
description: The name of the audio file on-disk
pointer:
$ref: '#/components/schemas/Prescreen-Pointer'
err:
type: string
description: 'A machine-readable error message, present if status is "err"'
accepted:
type: boolean
description: 'Whether the submission passed the pre-screening, present if status is "finished"'
required:
- status
- name
- pointer
'404':
$ref: '#/components/responses/Error'
operationId: get_prescreen_status
description: 'Use a pointer to get the status of the submission and whether it passed the pre-screening if it is finished, or get the error that occurred if there was one.'
/profile:
get:
summary: Get Private Profile
tags:
- frontend
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/User'
examples:
new_user:
value:
_id: kaJ73KMV78tIj3a92xmn83ikjla1
pfp:
- 0
username: John Doe
usernameSpecs: ''
ratings:
all: 1
literature: 1
totalQuestionsPlayed: 0
totalGames: 0
coins: 0
coinsCumulative: 0
activityOverview: []
recordedAudios: []
permLevel: normal
playTime: 0
creationDate: '2019-08-24T14:15:22.124643Z'
'401':
description: Unauthorized
'404':
description: Not Found
'500':
$ref: '#/components/responses/Error'
operationId: get_profile
parameters: []
description: Retrieve all profile information associated with the user specified in the Auth-Token header. This is intended to be called by solely the front-end.
security:
- Firebase-Auth: []
post:
summary: Create Profile
operationId: create_profile
responses:
'201':
description: Created
'400':
$ref: '#/components/responses/Error'
description: Create a user profile stub as a client
requestBody:
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
pfp:
$ref: '#/components/schemas/PFP-Specs'
username:
$ref: '#/components/schemas/Username'
required:
- pfp
- username
examples:
user-stub:
value:
pfp:
- 0
username: John Doe
description: The fields to set in the profile
tags:
- frontend
parameters: []
security:
- Firebase-Auth: []
patch:
summary: Update Profile
operationId: modify_profile
responses:
'200':
description: OK
'400':
$ref: '#/components/responses/Error'
'401':
description: Unauthorized
'404':
$ref: '#/components/responses/Error'
'500':
description: Internal Server Error
description: Update the user's profile as the user
parameters: []
requestBody:
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
pfp:
$ref: '#/components/schemas/PFP-Specs'
username:
$ref: '#/components/schemas/Username'
usernameSpecs:
$ref: '#/components/schemas/Username-Specs'
description: The fields to update. Can include any of the properties listed in the schema.
tags:
- frontend
security:
- Firebase-Auth: []
delete:
summary: Remove Profile
operationId: delete_profile
responses:
'200':
description: OK
'401':
description: Unauthorized
'404':
$ref: '#/components/responses/Error'
'500':
description: Internal Server Error
description: 'Delete the user''s profile as the user, along with all associated data.'
tags:
- frontend
parameters: []
security:
- Firebase-Auth: []
'/profile/{username}':
parameters:
- schema:
type: string
name: username
in: path
required: true
get:
summary: Get Public Profile
tags:
- frontend
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Public-Profile'
'400':
description: Bad Request
'401':
description: Unauthorized
'404':
description: Not Found
'500':
description: Internal Server Error
operationId: get_other_profile
description: Retrieve the public profile of another user
parameters:
- schema: {}
in: query
name: basic
description: Include this keyword to get a reduced public profile.
security:
- Firebase-Auth: []
patch:
summary: Change Other Profile
tags:
- frontend
responses:
'200':
description: OK
'400':
description: Bad Request
'401':
description: Unauthorized
'404':
$ref: '#/components/responses/Error'
'500':
description: Internal Server Error
operationId: modify_other_profile
description: Modify the profile of another user. Can modify any field except `permLevel`. Requires elevated permissions.
parameters: []
requestBody:
content:
application/json:
schema:
type: object
properties:
pfp:
$ref: '#/components/schemas/PFP-Specs'
username:
$ref: '#/components/schemas/Username'
usernameSpecs:
$ref: '#/components/schemas/Username-Specs'
ratings:
$ref: '#/components/schemas/Game-Ratings'
totalQuestionsPlayed:
type: integer
totalGames:
type: integer
coins:
type: integer
coinsCumulative:
type: integer
activityOverview:
type: array
items:
$ref: '#/components/schemas/User-Action'
recordedAudios:
type: array
items:
$ref: '#/components/schemas/Recording'
description: The fields to update. Can include any of the properties listed below.
security:
- Firebase-Auth: []
delete: