Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTS for Contained Levels #26381

Merged
merged 15 commits into from
Jan 21, 2019
Merged

TTS for Contained Levels #26381

merged 15 commits into from
Jan 21, 2019

Conversation

epeach
Copy link

@epeach epeach commented Dec 15, 2018

Adds TTS for Contained Levels on CSF and CSD/P

For free response levels: the prompt is read
For multiple choice levels: the context, question, and answers are read

Because contained levels in CSF are not displayed in the white speech-bubble, the CSS for the inline audio has been slightly updated, per design spec from Mark.

CSF TTS on non-contained level:
screenshot from 2018-12-12 17-17-41

CSF TTS on contained level:
screenshot from 2018-12-14 17-40-45

The new audio files have not been generated yet and should be generated prior to this PR getting merged.

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

Given I am a student
And I am on "http://studio.code.org/s/allthettsthings/stage/1/puzzle/1"
And I wait for the page to fully load

# note: we expect audio for csd instructions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This comment refers to CSD but this test now covers CSF (I think?)

Then I wait until element ".inline-audio" is visible
Then I see 1 of jquery selector .inline-audio
#Checks that inline audio does not disappear (indication of error)
And I listen to the 0th inline audio element
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 We should really extend this step so we can write "first" instead of "0th."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would worry about confusion between the "first" and "1st" cases :/

Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

all_instructions = []

contained_levels.each {|contained| all_instructions.push(contained_level_text(contained))}
contained_levels.empty? ? nil : all_instructions * "\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be all_instructions.empty??

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original intention here was: 'if there are no contained levels, then just return nil', but implementation-wise I agree that checking all_instructions makes more sense.

@epeach
Copy link
Author

epeach commented Jan 16, 2019

@islemaster or @Hamms - Can I get one more look at the short_instructions part? Thanks!

@@ -197,7 +198,7 @@ def tts_for_contained_level
def contained_level_text(contained)
# For multi questions, create a string for TTS of the markdown, question, and answers
if contained.long_instructions.nil?
combined_text = contained.properties["markdown"] + "\n"
combined_text = contained.properties["markdown"].nil? ? "" : contained.properties["markdown"] + "\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the "\n" necessary here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly, a space is needed to make sure that when the strings are concatenated the last word of one string and the first word of the next don't become one word - which Sharon would then read as one word. I just chose a "\n" for debugging simplicity, but we could use any other whitespace there.

Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me why it's necessary to use contained text in the short instructions TTS; do we actually display short instructions for contained levels?


test 'tts_short_instructions_text for contained levels' do
contained_level_freeresponse = create :level, name: 'contained level 1', type: 'FreeResponse', properties: {
markdown_instructions: "This is contained"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we prefer long_instructions over markdown_instructions for this now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't display short instructions for contained levels, but we want to support TTS on contained levels. When I turned on TTS on those levels, the levels which default to short instructions were playing the audio for instructions that are not (I think, never) displayed. So this change is designed to override those situations - if there are contained levels, we'll use that TTS audio, whether or not the containing level defaults to short or long instructions (since those short/long instructions shouldn't be displayed, as far as I know).

Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@epeach epeach merged commit 7b2eb79 into staging Jan 21, 2019
@epeach epeach deleted the TTS-prediction-CSP branch January 22, 2019 19:12
Hamms added a commit that referenced this pull request Jul 31, 2020
Specifically, update the script which generates non-English TTS audio to use the general "tts_*_text" methods, which enables them to see the new contained levels content added in #26381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants