Created
December 8, 2017 15:38
-
-
Save jnd71/612c09c6a62585d05d4281bb0d9f3d6c to your computer and use it in GitHub Desktop.
Scala Programming Taste
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Which of these is a better style? Is there much of a difference? | |
def createMicrosoftAudio0(utterance: Utterance, svc: MsSynthSvc = MicrosoftSpeech.Synthesize): Future[SynthesizedSpeech] = { | |
if(!utterance.text.isDefined) return Future.exception(new UtteranceTextNotFound(utterance)) | |
val req = SynthesizeRequest(utterance.convo.id, utterance.text.get) | |
for { | |
resp <- svc(req) | |
} yield SynthesizedSpeed(resp._1, resp._2) | |
} | |
def createMicrosoftAudio1(utterance: Utterance, svc: MsSynthSvc = MicrosoftSpeech.Synthesize): Future[SynthesizedSpeech] = { | |
if(utterance.emptyText) return Future.exception(new UtteranceTextNotFound(utterance)) | |
val req = SynthesizeRequest.fromUtterance(utterance) | |
svc(req).map(SynthesizedSpeech) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given the generalised Speech client façade I've created, direct "extractors" would prolly be nice:
and then