Skip to content
QiTASC.com / Steps and Compound Steps / Speech-to-Text Steps /
Using Speech-to-Text in Test Cases
/ .. / .. /
Using Speech-to-Text in Test Cases





Using Speech-to-Text in Test Cases

There are two ways of accessing speech-to-text functionality:

  • Via the built-in SpeechToText model

  • Via the speech-to-text Stepdef

Speech-to-Text Step

The Speech-to-Text step performs recognition on a given file, which is specified as a reference to an object in the Scenario Execution Context, and stores the result in the specified identifier in the Scenario Execution Context. The step will fail if the recognition fails to produce any results for the given audio file.

Syntax

1
perform speech-to-text recognition on <audioFile Identifier> with language <language Language> and save as <result Identifier>

Parameters

  • audioFile - The name of the scenario execution context object that contains the audio file to recognize

  • language - The same language as specified in the SpeechToText model, which must be supported by the Google Cloud Speech-to-Text API

  • result - The scenario execution object key where the recognized text should be stored

Feature File Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Feature: SpeechToText

  Scenario: speech-to-text

    Given a phone as A:
      * of type Android
      * with profile audioService

    And A starts a call to "123456789" as call1:
      * caller records audio from connect to disconnect
      * call duration is 5 seconds

     And within 20 seconds, expect the call call1 to connect
     And within 30 seconds, expect the call call1 to disconnect

    Then perform speech-to-text recognition on call1.recordings.A.connect_to_disconnect with language en-US and save as RESULT
    And verify RESULT == "expected recognized text"

Speech-to-Text Stepdefs and Models

The Speech-To-Text Built-ins and File Built-ins provide access to the audio file that will be recognized by intaQt. These functions may be combined.

Speech to Text Built-in

The Speech-to-Text built-in provides a function that takes the audio file and language as parameters and returns an object containing the recognized test. The audio file must be accessed through File Built-ins, which are described in the following section.

Syntax

1
<speechToText Result> := SpeechToText.recognize(<audioFile File>, <language String>)

Returns

The recognition result is an object containing information about the status of the operation and the recognized text:

1
2
assert result.isOk()
println(result.text)    // text is valid only if isOk() is true

Parameters

  • audioFile - A file as provided by File.fromProject or File.fromSystem builtins

  • language - One of the languages supported by the Google Cloud Speech-to-Text API

Example

1
speechToText := SpeechToText.recognize(audioFile, "de-De")

File Built-ins

The File.fromProject or File.fromSystem Built-ins may be used to access the audio files used with the speech-to-text stepdef. Additional information is available in the File Built-ins section.

File From Project

This function returns the file from the current execution context's project folder.

Syntax

1
<file File> := File.fromProject(<path String>)

Returns
The specified file.

Parameter

  • path - The relative path to the project root folder

Example

1
audioFile := File.fromProject("audio.wav")

File From System

This function creates a new file instance by converting the specified path name string into an abstract path name. If the specified string is empty, then the result is an empty abstract path name.

Syntax

1
<file File> := File.fromSystem(<pathname String>)

Returns
The new file instance.

Parameter

  • pathname - The path's name

Example 1 - Allocating the File with Its Global Path from the System

1
audioFile := File.fromSystem("audio.wav")

Combining the SpeechToText and File Built-ins

The example below demonstrates a Stepdef that accesses the audio file using the File Built-ins and then uses the SpeechToText Built-in to recognize the text.

Example

1
2
3
4
5
6
7
stepdef "do speech-to-text"
    audioFile := File.fromProject("audio.wav")

    result := SpeechToText.recognize(audioFile, "de-DE")
    assert result.isOk()
    println(result.text)
end