Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question: Largest Hub for Question Solutions and Expert Answers

Querify Question: Largest Hub for Question Solutions and Expert Answers Logo Querify Question: Largest Hub for Question Solutions and Expert Answers Logo

Querify Question: Largest Hub for Question Solutions and Expert Answers Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 784020

Querify Question: Largest Hub for Question Solutions and Expert Answers Latest Articles

admin
  • 157
adminEnlightened
Asked: July 14, 20242024-07-14T05:08:24+00:00 2024-07-14T05:08:24+00:00

how to simulate the transcription result with pytest without actually sending data to azure speech api

  • 157

I'm having trouble coming up with a pytest function to test the function below:

Is there a way to mock any function/object such that I can fake a transcription result that's consistent every time I run the test and not send any data to the actual Azure Speech service (so it doesn't get billed)?

def transcribe_azure_speech_file(speech_file):     speech_config = speechsdk.SpeechConfig(subscription=SUBSCRIPTION_KEY, region=REGION)     audio_input = speechsdk.AudioConfig(filename=speech_file)     auto_source_lang_config = speechsdk.AutoDetectSourceLanguageConfig(languages=["en-US"])     speech_recognizer = speechsdk.SpeechRecognizer(         speech_config=speech_config,         audio_config=audio_input,         auto_detect_source_language_config=auto_source_lang_config     )      transcripts = []     done = False      def _stop_cb(evt):         """callback that signals to stop continuous recognition upon receiving an event `evt`"""         print('CLOSING on {}'.format(evt))         nonlocal done         done = True      def _recognized_event(evt):         result = evt.result         start_time = result.offset / 10e6         end_time = start_time + result.duration / 10e6          transcripts.append(             {                 "transcript": result.text,                 "start_time": start_time,                 "end_time": end_time,             }         )      # connect callbacks to the events fired by the speech recognizer     speech_recognizer.recognized.connect(_recognized_event)     # stop continuous recognition on either session stopped or canceled events     speech_recognizer.session_stopped.connect(_stop_cb)     speech_recognizer.canceled.connect(_stop_cb)      # start continuous speech recognition     speech_recognizer.start_continuous_recognition()     while not done:         time.sleep(0.25)      speech_recognizer.stop_continuous_recognition()      return transcripts 

azurecognitiveservicesazurespeechmockingpytestpython
  • 0 0 Answers
  • 1k Views
  • 0 Followers
  • 1k
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 1mil
  • Answer 1
  • Best Answers 0
  • Users 40k
  • Popular
  • Answers
  • admin

    vba code excel range not pasting to outlook properly

    • 1 Answer
  • MilaBrext

    Заказать Хавал - только у нас вы найдете цены ниже ...

    • 0 Answers
  • admin

    Creating a Regex to Match the First N Characters of ...

    • 0 Answers
  • Reda
    Reda added an answer Convert Range to Text February 27, 2025 at 8:30 pm

Top Members

admin

admin

  • 1mil Questions
  • 855 Points
Enlightened
Reda

Reda

  • 0 Questions
  • 22 Points
Begginer
Aria Carter

Aria Carter

  • 0 Questions
  • 21 Points
Begginer

Trending Tags

android azuredevops azurepipelines c database debugging decimal docker html ios java javascript jquery php python reactjs regex rubyonrails sql vlc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question: Largest Hub for Question Solutions and Expert Answers

Querify Question: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.