diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 3238a4cc..9a2744e1 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 8.0.1 +current_version = 8.1.0 commit = True message = Bump version: {current_version} → {new_version} [skip ci] diff --git a/examples/microphone-speech-to-text.py b/examples/microphone-speech-to-text.py index 9174de74..fb0fbd1a 100644 --- a/examples/microphone-speech-to-text.py +++ b/examples/microphone-speech-to-text.py @@ -72,8 +72,7 @@ def recognize_using_weboscket(*args): mycallback = MyRecognizeCallback() speech_to_text.recognize_using_websocket(audio=audio_source, content_type='audio/l16; rate=44100', - recognize_callback=mycallback, - interim_results=True) + recognize_callback=mycallback) ############################################### #### Prepare the for recording using Pyaudio ## diff --git a/ibm_watson/discovery_v2.py b/ibm_watson/discovery_v2.py index 3bfead3d..f3ede4e6 100644 --- a/ibm_watson/discovery_v2.py +++ b/ibm_watson/discovery_v2.py @@ -143,6 +143,8 @@ def create_project( project and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from + IBM Cloud-managed instances only. :param DefaultQueryParams default_query_parameters: (optional) Default query parameters for this project. :param dict headers: A `dict` containing the request headers @@ -204,8 +206,9 @@ def get_project( Get details on the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ProjectDetails` object @@ -256,8 +259,9 @@ def update_project( Update the specified project's name. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str name: (optional) The new name to give this project. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -317,8 +321,9 @@ def delete_project( **Important:** Deleting a project deletes everything that is part of the specified project, including all collections. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -369,8 +374,9 @@ def list_fields( Gets a list of the unique fields (and their types) stored in the specified collections. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param List[str] collection_ids: (optional) Comma separated list of the collection IDs. If this parameter is not specified, all collections in the project are used. @@ -427,8 +433,9 @@ def list_collections( Lists existing collections for the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ListCollectionsResponse` object @@ -474,6 +481,7 @@ def create_collection( *, description: Optional[str] = None, language: Optional[str] = None, + ocr_enabled: Optional[bool] = None, enrichments: Optional[List['CollectionEnrichment']] = None, **kwargs, ) -> DetailedResponse: @@ -482,13 +490,17 @@ def create_collection( Create a new collection in the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str name: The name of the collection. :param str description: (optional) A description of the collection. :param str language: (optional) The language of the collection. For a list of supported languages, see the [product documentation](/docs/discovery-data?topic=discovery-data-language-support). + :param bool ocr_enabled: (optional) If set to `true`, optical character + recognition (OCR) is enabled. For more information, see [Optical character + recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). :param List[CollectionEnrichment] enrichments: (optional) An array of enrichments that are applied to this collection. To get a list of enrichments that are available for a project, use the [List @@ -524,6 +536,7 @@ def create_collection( 'name': name, 'description': description, 'language': language, + 'ocr_enabled': ocr_enabled, 'enrichments': enrichments, } data = {k: v for (k, v) in data.items() if v is not None} @@ -561,9 +574,11 @@ def get_collection( Get details about the specified collection. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `CollectionDetails` object @@ -612,6 +627,7 @@ def update_collection( *, name: Optional[str] = None, description: Optional[str] = None, + ocr_enabled: Optional[bool] = None, enrichments: Optional[List['CollectionEnrichment']] = None, **kwargs, ) -> DetailedResponse: @@ -632,11 +648,16 @@ def update_collection( enrichments are applied, specify an empty `normalizations` object (`[]`) in the request. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param str name: (optional) The new name of the collection. :param str description: (optional) The new description of the collection. + :param bool ocr_enabled: (optional) If set to `true`, optical character + recognition (OCR) is enabled. For more information, see [Optical character + recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). :param List[CollectionEnrichment] enrichments: (optional) An array of enrichments that are applied to this collection. :param dict headers: A `dict` containing the request headers @@ -665,6 +686,7 @@ def update_collection( data = { 'name': name, 'description': description, + 'ocr_enabled': ocr_enabled, 'enrichments': enrichments, } data = {k: v for (k, v) in data.items() if v is not None} @@ -704,9 +726,11 @@ def delete_collection( Deletes the specified collection from the project. All documents stored in the specified collection and not shared is also deleted. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -772,9 +796,11 @@ def list_documents( **Note**: This method is available only from Cloud Pak for Data version 4.0.9 and later installed instances, and from IBM Cloud-managed instances. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param int count: (optional) The maximum number of documents to return. Up to 1,000 documents are returned by default. The maximum number allowed is 10,000. @@ -893,9 +919,11 @@ def add_document( a file is added to a collection, see the [product documentation](/docs/discovery-data?topic=discovery-data-index-overview#field-name-limits). - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param BinaryIO file: (optional) **Add a document**: The content of the document to ingest. For the supported file types and maximum supported file size limits when adding a document, see [the @@ -989,9 +1017,11 @@ def get_document( **Note**: This method is available only from Cloud Pak for Data version 4.0.9 and later installed instances, and from IBM Cloud-managed instances. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param str document_id: The ID of the document. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -1066,9 +1096,11 @@ def update_document( existing child documents are overwritten, even if the updated version of the document has fewer child documents. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param str document_id: The ID of the document. :param BinaryIO file: (optional) **Add a document**: The content of the document to ingest. For the supported file types and maximum supported file @@ -1175,9 +1207,11 @@ def delete_document( document instead. You can get the document ID of the original document from the `parent_document_id` of the subdocument result. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param str document_id: The ID of the document. :param bool x_watson_discovery_force: (optional) When `true`, the uploaded document is added to the collection even if the data for that collection is @@ -1269,8 +1303,9 @@ def query( The length of the UTF-8 encoding of the POST body cannot exceed 10,000 bytes, which is roughly equivalent to 10,000 characters in English. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param List[str] collection_ids: (optional) A comma-separated list of collection IDs to be queried against. :param str filter: (optional) Searches for documents that match the @@ -1419,8 +1454,9 @@ def get_autocompletion( based on terms from the project's search history, and the project does not learn from previous user choices. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str prefix: The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to `hot`, `housing`, or `how`. :param List[str] collection_ids: (optional) Comma separated list of the @@ -1493,9 +1529,11 @@ def query_collection_notices( Finds collection-level notices (errors and warnings) that are generated when documents are ingested. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param str filter: (optional) Searches for documents that match the Discovery Query Language criteria that is specified as input. Filter calls are cached and are faster than query calls because the results are not @@ -1584,8 +1622,9 @@ def query_notices( Finds project-level notices (errors and warnings). Currently, project-level notices are generated by relevancy training. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str filter: (optional) Searches for documents that match the Discovery Query Language criteria that is specified as input. Filter calls are cached and are faster than query calls because the results are not @@ -1671,9 +1710,11 @@ def get_stopword_list( about the default stop words lists that are applied to queries, see [the product documentation](/docs/discovery-data?topic=discovery-data-stopwords). - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `StopWordList` object @@ -1737,9 +1778,11 @@ def create_stopword_list( stop words. For information about the default stop words lists per language, see [the product documentation](/docs/discovery-data?topic=discovery-data-stopwords). - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param List[str] stopwords: (optional) List of stop words. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -1803,9 +1846,11 @@ def delete_stopword_list( collection. After a custom stop words list is deleted, the default stop words list is used. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -1858,9 +1903,11 @@ def list_expansions( Returns the current expansion list for the specified collection. If an expansion list is not specified, an empty expansions array is returned. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `Expansions` object @@ -1918,9 +1965,11 @@ def create_expansions( of a query beyond exact matches. The maximum number of expanded terms allowed per collection is 5,000. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param List[Expansion] expansions: An array of query expansion definitions. Each object in the **expansions** array represents a term or set of terms that will be expanded into other terms. Each expansion object can be @@ -1998,9 +2047,11 @@ def delete_expansions( Removes the expansion information for this collection. To disable query expansion for a collection, delete the expansion list. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -2055,8 +2106,9 @@ def get_component_settings( Returns default configuration settings for components. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ComponentSettingsResponse` object @@ -2110,8 +2162,9 @@ def list_training_queries( List the training queries for the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `TrainingQuerySet` object @@ -2161,8 +2214,9 @@ def delete_training_queries( Removes all training queries for the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -2217,8 +2271,9 @@ def create_training_query( and natural language query. **Note**: You cannot apply relevancy training to a `content_mining` project type. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str natural_language_query: The natural text query that is used as the training query. :param List[TrainingExample] examples: Array of training examples. @@ -2294,8 +2349,9 @@ def get_training_query( Get details for a specific training data query, including the query string and all examples. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str query_id: The ID of the query used for training. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -2354,8 +2410,9 @@ def update_training_query( Updates an existing training query and its examples. You must resubmit all of the examples with the update request. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str query_id: The ID of the query used for training. :param str natural_language_query: The natural text query that is used as the training query. @@ -2436,8 +2493,9 @@ def delete_training_query( To delete an example, use the *Update a training query* method and omit the example that you want to delete from the example set. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param str query_id: The ID of the query used for training. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -2495,8 +2553,9 @@ def list_enrichments( *Sentiment of Phrases* enrichments might be listed, but are reserved for internal use only. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `Enrichments` object @@ -2550,8 +2609,9 @@ def create_enrichment( to a collection in the project, use the [Collections API](/apidocs/discovery-data#createcollection). - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param CreateEnrichment enrichment: Information about a specific enrichment. :param BinaryIO file: (optional) The enrichment file to upload. Expected @@ -2619,9 +2679,11 @@ def get_enrichment( Get details about a specific enrichment. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str enrichment_id: The ID of the enrichment. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str enrichment_id: The Universally Unique Identifier (UUID) of the + enrichment. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `Enrichment` object @@ -2677,9 +2739,11 @@ def update_enrichment( Updates an existing enrichment's name and description. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str enrichment_id: The ID of the enrichment. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str enrichment_id: The Universally Unique Identifier (UUID) of the + enrichment. :param str name: A new name for the enrichment. :param str description: (optional) A new description for the enrichment. :param dict headers: A `dict` containing the request headers @@ -2746,9 +2810,11 @@ def delete_enrichment( Deletes an existing enrichment from the specified project. **Note:** Only enrichments that have been manually created can be deleted. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str enrichment_id: The ID of the enrichment. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str enrichment_id: The Universally Unique Identifier (UUID) of the + enrichment. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -2804,8 +2870,9 @@ def list_document_classifiers( Get a list of the document classifiers in a project. Returns only the name and classifier ID of each document classifier. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `DocumentClassifiers` object @@ -2864,8 +2931,9 @@ def create_document_classifier( **Note:** This method is supported on installed instances (IBM Cloud Pak for Data) or IBM Cloud-managed Premium or Enterprise plan instances. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. :param BinaryIO training_data: The training data CSV file to upload. The CSV file must have headers. The file must include a field that contains the text you want to classify and a field that contains the classification @@ -2942,9 +3010,11 @@ def get_document_classifier( Get details about a specific document classifier. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `DocumentClassifier` object @@ -3002,9 +3072,11 @@ def update_document_classifier( Update the document classifier name or description, update the training data, or add or update the test data. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. :param UpdateDocumentClassifier classifier: An object that contains a new name or description for a document classifier, updated training data, or new or updated test data. @@ -3083,9 +3155,11 @@ def delete_document_classifier( Deletes an existing document classifier from the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -3142,9 +3216,11 @@ def list_document_classifier_models( Get a list of the document classifier models in a project. Returns only the name and model ID of each document classifier model. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `DocumentClassifierModels` object @@ -3208,9 +3284,11 @@ def create_document_classifier_model( **Note:** This method is supported on installed intances (IBM Cloud Pak for Data) or IBM Cloud-managed Premium or Enterprise plan instances. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. :param str name: The name of the document classifier model. :param str description: (optional) A description of the document classifier model. @@ -3304,10 +3382,13 @@ def get_document_classifier_model( Get details about a specific document classifier model. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. - :param str model_id: The ID of the classifier model. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. + :param str model_id: The Universally Unique Identifier (UUID) of the + classifier model. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `DocumentClassifierModel` object @@ -3367,10 +3448,13 @@ def update_document_classifier_model( Update the document classifier model name or description. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. - :param str model_id: The ID of the classifier model. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. + :param str model_id: The Universally Unique Identifier (UUID) of the + classifier model. :param str name: (optional) A new name for the enrichment. :param str description: (optional) A new description for the enrichment. :param dict headers: A `dict` containing the request headers @@ -3438,10 +3522,13 @@ def delete_document_classifier_model( Deletes an existing document classifier model from the specified project. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str classifier_id: The ID of the classifier. - :param str model_id: The ID of the classifier model. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str classifier_id: The Universally Unique Identifier (UUID) of the + classifier. + :param str model_id: The Universally Unique Identifier (UUID) of the + classifier model. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -3518,9 +3605,11 @@ def analyze_document( **Note:** This method is supported with Enterprise plan deployments and installed deployments only. - :param str project_id: The ID of the project. This information can be found - from the *Integrate and Deploy* page in Discovery. - :param str collection_id: The ID of the collection. + :param str project_id: The Universally Unique Identifier (UUID) of the + project. This information can be found from the *Integrate and Deploy* page + in Discovery. + :param str collection_id: The Universally Unique Identifier (UUID) of the + collection. :param BinaryIO file: (optional) **Add a document**: The content of the document to ingest. For the supported file types and maximum supported file size limits when adding a document, see [the @@ -4069,7 +4158,8 @@ class Collection: """ A collection for storing documents. - :param str collection_id: (optional) The unique identifier of the collection. + :param str collection_id: (optional) The Universally Unique Identifier (UUID) of + the collection. :param str name: (optional) The name of the collection. """ @@ -4135,13 +4225,17 @@ class CollectionDetails: """ A collection for storing documents. - :param str collection_id: (optional) The unique identifier of the collection. + :param str collection_id: (optional) The Universally Unique Identifier (UUID) of + the collection. :param str name: The name of the collection. :param str description: (optional) A description of the collection. :param datetime created: (optional) The date that the collection was created. :param str language: (optional) The language of the collection. For a list of supported languages, see the [product documentation](/docs/discovery-data?topic=discovery-data-language-support). + :param bool ocr_enabled: (optional) If set to `true`, optical character + recognition (OCR) is enabled. For more information, see [Optical character + recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). :param List[CollectionEnrichment] enrichments: (optional) An array of enrichments that are applied to this collection. To get a list of enrichments that are available for a project, use the [List enrichments](#listenrichments) @@ -4163,6 +4257,7 @@ def __init__( description: Optional[str] = None, created: Optional[datetime] = None, language: Optional[str] = None, + ocr_enabled: Optional[bool] = None, enrichments: Optional[List['CollectionEnrichment']] = None, smart_document_understanding: Optional[ 'CollectionDetailsSmartDocumentUnderstanding'] = None, @@ -4175,6 +4270,9 @@ def __init__( :param str language: (optional) The language of the collection. For a list of supported languages, see the [product documentation](/docs/discovery-data?topic=discovery-data-language-support). + :param bool ocr_enabled: (optional) If set to `true`, optical character + recognition (OCR) is enabled. For more information, see [Optical character + recognition](/docs/discovery-data?topic=discovery-data-collections#ocr). :param List[CollectionEnrichment] enrichments: (optional) An array of enrichments that are applied to this collection. To get a list of enrichments that are available for a project, use the [List @@ -4189,6 +4287,7 @@ def __init__( self.description = description self.created = created self.language = language + self.ocr_enabled = ocr_enabled self.enrichments = enrichments self.smart_document_understanding = smart_document_understanding @@ -4210,6 +4309,8 @@ def from_dict(cls, _dict: Dict) -> 'CollectionDetails': args['created'] = string_to_datetime(created) if (language := _dict.get('language')) is not None: args['language'] = language + if (ocr_enabled := _dict.get('ocr_enabled')) is not None: + args['ocr_enabled'] = ocr_enabled if (enrichments := _dict.get('enrichments')) is not None: args['enrichments'] = [ CollectionEnrichment.from_dict(v) for v in enrichments @@ -4240,6 +4341,8 @@ def to_dict(self) -> Dict: _dict['created'] = datetime_to_string(getattr(self, 'created')) if hasattr(self, 'language') and self.language is not None: _dict['language'] = self.language + if hasattr(self, 'ocr_enabled') and self.ocr_enabled is not None: + _dict['ocr_enabled'] = self.ocr_enabled if hasattr(self, 'enrichments') and self.enrichments is not None: enrichments_list = [] for v in self.enrichments: @@ -5949,8 +6052,8 @@ class DocumentClassifier: """ Information about a document classifier. - :param str classifier_id: (optional) A unique identifier of the document - classifier. + :param str classifier_id: (optional) The Universally Unique Identifier (UUID) of + the document classifier. :param str name: A human-readable name of the document classifier. :param str description: (optional) A description of the document classifier. :param datetime created: (optional) The date that the document classifier was @@ -6143,7 +6246,8 @@ class DocumentClassifierEnrichment: An object that describes enrichments that are applied to the training and test data that is used by the document classifier. - :param str enrichment_id: A unique identifier of the enrichment. + :param str enrichment_id: The Universally Unique Identifier (UUID) of the + enrichment. :param List[str] fields: An array of field names where the enrichment is applied. """ @@ -6156,7 +6260,8 @@ def __init__( """ Initialize a DocumentClassifierEnrichment object. - :param str enrichment_id: A unique identifier of the enrichment. + :param str enrichment_id: The Universally Unique Identifier (UUID) of the + enrichment. :param List[str] fields: An array of field names where the enrichment is applied. """ @@ -6218,8 +6323,8 @@ class DocumentClassifierModel: """ Information about a document classifier model. - :param str model_id: (optional) A unique identifier of the document classifier - model. + :param str model_id: (optional) The Universally Unique Identifier (UUID) of the + document classifier model. :param str name: A human-readable name of the document classifier model. :param str description: (optional) A description of the document classifier model. @@ -6235,8 +6340,8 @@ class DocumentClassifierModel: :param str status: (optional) The status of the training run. :param ClassifierModelEvaluation evaluation: (optional) An object that contains information about a trained document classifier model. - :param str enrichment_id: (optional) A unique identifier of the enrichment that - is generated by this document classifier model. + :param str enrichment_id: (optional) The Universally Unique Identifier (UUID) of + the enrichment that is generated by this document classifier model. :param datetime deployed_at: (optional) The date that the document classifier model was deployed. """ @@ -6271,8 +6376,9 @@ def __init__( :param str status: (optional) The status of the training run. :param ClassifierModelEvaluation evaluation: (optional) An object that contains information about a trained document classifier model. - :param str enrichment_id: (optional) A unique identifier of the enrichment - that is generated by this document classifier model. + :param str enrichment_id: (optional) The Universally Unique Identifier + (UUID) of the enrichment that is generated by this document classifier + model. """ self.model_id = model_id self.name = name @@ -6775,7 +6881,8 @@ class Enrichment: """ Information about a specific enrichment. - :param str enrichment_id: (optional) The unique identifier of this enrichment. + :param str enrichment_id: (optional) The Universally Unique Identifier (UUID) of + this enrichment. :param str name: (optional) The human readable name for this enrichment. :param str description: (optional) The description of this enrichment. :param str type: (optional) The type of this enrichment. @@ -6906,12 +7013,12 @@ class EnrichmentOptions: :param str result_field: (optional) The name of the result document field that this enrichment creates. Required when **type** is `rule_based` or `classifier`. Not valid when creating any other type of enrichment. - :param str classifier_id: (optional) A unique identifier of the document - classifier. Required when **type** is `classifier`. Not valid when creating any - other type of enrichment. - :param str model_id: (optional) A unique identifier of the document classifier - model. Required when **type** is `classifier`. Not valid when creating any other - type of enrichment. + :param str classifier_id: (optional) The Universally Unique Identifier (UUID) of + the document classifier. Required when **type** is `classifier`. Not valid when + creating any other type of enrichment. + :param str model_id: (optional) The Universally Unique Identifier (UUID) of the + document classifier model. Required when **type** is `classifier`. Not valid + when creating any other type of enrichment. :param float confidence_threshold: (optional) Specifies a threshold. Only classes with evaluation confidence scores that are higher than the specified threshold are included in the output. Optional when **type** is `classifier`. @@ -6978,12 +7085,12 @@ def __init__( :param str result_field: (optional) The name of the result document field that this enrichment creates. Required when **type** is `rule_based` or `classifier`. Not valid when creating any other type of enrichment. - :param str classifier_id: (optional) A unique identifier of the document - classifier. Required when **type** is `classifier`. Not valid when creating - any other type of enrichment. - :param str model_id: (optional) A unique identifier of the document - classifier model. Required when **type** is `classifier`. Not valid when - creating any other type of enrichment. + :param str classifier_id: (optional) The Universally Unique Identifier + (UUID) of the document classifier. Required when **type** is `classifier`. + Not valid when creating any other type of enrichment. + :param str model_id: (optional) The Universally Unique Identifier (UUID) of + the document classifier model. Required when **type** is `classifier`. Not + valid when creating any other type of enrichment. :param float confidence_threshold: (optional) Specifies a threshold. Only classes with evaluation confidence scores that are higher than the specified threshold are included in the output. Optional when **type** is @@ -8185,13 +8292,16 @@ class ProjectDetails: """ Detailed information about the specified project. - :param str project_id: (optional) The unique identifier of this project. + :param str project_id: (optional) The Universally Unique Identifier (UUID) of + this project. :param str name: (optional) The human readable name of this project. :param str type: (optional) The type of project. The `content_intelligence` type is a *Document Retrieval for Contracts* project and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from IBM + Cloud-managed instances only. :param ProjectListDetailsRelevancyTrainingStatus relevancy_training_status: (optional) Relevancy training status information for this project. :param int collection_count: (optional) The number of collections configured in @@ -8220,6 +8330,8 @@ def __init__( project and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from + IBM Cloud-managed instances only. :param DefaultQueryParams default_query_parameters: (optional) Default query parameters for this project. """ @@ -8315,8 +8427,11 @@ class TypeEnum(str, Enum): and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from IBM + Cloud-managed instances only. """ + INTELLIGENT_DOCUMENT_PROCESSING = 'intelligent_document_processing' DOCUMENT_RETRIEVAL = 'document_retrieval' CONVERSATIONAL_SEARCH = 'conversational_search' CONTENT_MINING = 'content_mining' @@ -8328,13 +8443,16 @@ class ProjectListDetails: """ Details about a specific project. - :param str project_id: (optional) The unique identifier of this project. + :param str project_id: (optional) The Universally Unique Identifier (UUID) of + this project. :param str name: (optional) The human readable name of this project. :param str type: (optional) The type of project. The `content_intelligence` type is a *Document Retrieval for Contracts* project and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from IBM + Cloud-managed instances only. :param ProjectListDetailsRelevancyTrainingStatus relevancy_training_status: (optional) Relevancy training status information for this project. :param int collection_count: (optional) The number of collections configured in @@ -8360,6 +8478,8 @@ def __init__( project and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from + IBM Cloud-managed instances only. """ self.project_id = project_id self.name = name @@ -8439,8 +8559,11 @@ class TypeEnum(str, Enum): and the `other` type is a *Custom* project. The `content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only. + The Intelligent Document Processing (IDP) project type is available from IBM + Cloud-managed instances only. """ + INTELLIGENT_DOCUMENT_PROCESSING = 'intelligent_document_processing' DOCUMENT_RETRIEVAL = 'document_retrieval' CONVERSATIONAL_SEARCH = 'conversational_search' CONTENT_MINING = 'content_mining' diff --git a/ibm_watson/speech_to_text_v1.py b/ibm_watson/speech_to_text_v1.py index c1b3be1f..0ad6d376 100644 --- a/ibm_watson/speech_to_text_v1.py +++ b/ibm_watson/speech_to_text_v1.py @@ -29,8 +29,8 @@ transcription accuracy. Effective **31 July 2023**, all previous-generation models will be removed from the service and the documentation. Most previous-generation models were deprecated on 15 March -2022. You must migrate to the equivalent next-generation model by 31 July 2023. For more -information, see [Migrating to next-generation +2022. You must migrate to the equivalent large speech model or next-generation model by 31 +July 2023. For more information, see [Migrating to large speech models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate).{: deprecated} For speech recognition, the service supports synchronous and asynchronous HTTP @@ -196,6 +196,7 @@ def recognize( *, content_type: Optional[str] = None, model: Optional[str] = None, + speech_begin_event: Optional[bool] = None, language_customization_id: Optional[str] = None, acoustic_customization_id: Optional[str] = None, base_model_version: Optional[str] = None, @@ -281,31 +282,36 @@ def recognize( fails. **See also:** [Supported audio formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats). - ### Next-generation models - The service supports next-generation `Multimedia` (16 kHz) and `Telephony` (8 - kHz) models for many languages. Next-generation models have higher throughput than - the service's previous generation of `Broadband` and `Narrowband` models. When you - use next-generation models, the service can return transcriptions more quickly and - also provide noticeably better transcription accuracy. - You specify a next-generation model by using the `model` query parameter, as you - do a previous-generation model. Most next-generation models support the - `low_latency` parameter, and all next-generation models support the - `character_insertion_bias` parameter. These parameters are not available with - previous-generation models. - Next-generation models do not support all of the speech recognition parameters - that are available for use with previous-generation models. Next-generation models - do not support the following parameters: + ### Large speech models and Next-generation models + The service supports large speech models and next-generation `Multimedia` (16 + kHz) and `Telephony` (8 kHz) models for many languages. Large speech models and + next-generation models have higher throughput than the service's previous + generation of `Broadband` and `Narrowband` models. When you use large speech + models and next-generation models, the service can return transcriptions more + quickly and also provide noticeably better transcription accuracy. + You specify a large speech model or next-generation model by using the `model` + query parameter, as you do a previous-generation model. Only the next-generation + models support the `low_latency` parameter, and all large speech models and + next-generation models support the `character_insertion_bias` parameter. These + parameters are not available with previous-generation models. + Large speech models and next-generation models do not support all of the speech + recognition parameters that are available for use with previous-generation models. + Next-generation models do not support the following parameters: * `acoustic_customization_id` * `keywords` and `keywords_threshold` * `processing_metrics` and `processing_metrics_interval` * `word_alternatives_threshold` **Important:** Effective **31 July 2023**, all previous-generation models will be removed from the service and the documentation. Most previous-generation models - were deprecated on 15 March 2022. You must migrate to the equivalent - next-generation model by 31 July 2023. For more information, see [Migrating to - next-generation + were deprecated on 15 March 2022. You must migrate to the equivalent large speech + model or next-generation model by 31 July 2023. For more information, see + [Migrating to large speech models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). **See also:** + * [Large speech languages and + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages) + * [Supported features for large speech + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages#models-lsm-supported-features) * [Next-generation languages and models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng) * [Supported features for next-generation @@ -340,6 +346,14 @@ def recognize( recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use) * [Using the default model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-use#models-use-default). + :param bool speech_begin_event: (optional) If `true`, the service returns a + response object `SpeechActivity` which contains the time when a speech + activity is detected in the stream. This can be used both in standard and + low latency mode. This feature enables client applications to know that + some words/speech has been detected and the service is in the process of + decoding. This can be used in lieu of interim results in standard mode. See + [Using speech recognition + parameters](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-service-features#features-parameters). :param str language_customization_id: (optional) The customization ID (GUID) of a custom language model that is to be used with the recognition request. The base model of the specified custom language model must match @@ -374,6 +388,7 @@ def recognize( Specify a value between 0.0 and 1.0. Unless a different customization weight was specified for the custom model when the model was trained, the default value is: + * 0.5 for large speech models * 0.3 for previous-generation models * 0.2 for most next-generation models * 0.1 for next-generation English and Japanese models @@ -447,9 +462,10 @@ def recognize( (all dialects) transcription only. See [Smart formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). - :param int smart_formatting_version: (optional) Smart formatting version is - for next-generation models and that is supported in US English, Brazilian - Portuguese, French and German languages. + :param int smart_formatting_version: (optional) Smart formatting version + for large speech models and next-generation models is supported in US + English, Brazilian Portuguese, French, German, Spanish and French Canadian + languages. :param bool speaker_labels: (optional) If `true`, the response includes labels that identify which words were spoken by which participants in a multi-person exchange. By default, the service returns no speaker labels. @@ -459,9 +475,8 @@ def recognize( Australian English, US English, German, Japanese, Korean, and Spanish (both broadband and narrowband models) and UK English (narrowband model) transcription only. - * _For next-generation models,_ the parameter can be used with Czech, - English (Australian, Indian, UK, and US), German, Japanese, Korean, and - Spanish transcription only. + * _For large speech models and next-generation models,_ the parameter can + be used with all available languages. See [Speaker labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speaker-labels). :param str grammar_name: (optional) The name of a grammar that is to be @@ -535,8 +550,8 @@ def recognize( The values increase on a monotonic curve. Specifying one or two decimal places of precision (for example, `0.55`) is typically more than sufficient. - The parameter is supported with all next-generation models and with most - previous-generation models. See [Speech detector + The parameter is supported with all large speech models, next-generation + models and with most previous-generation models. See [Speech detector sensitivity](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-sensitivity) and [Language model support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). @@ -552,8 +567,8 @@ def recognize( The values increase on a monotonic curve. Specifying one or two decimal places of precision (for example, `0.55`) is typically more than sufficient. - The parameter is supported with all next-generation models and with most - previous-generation models. See [Background audio + The parameter is supported with all large speech models, next-generation + models and with most previous-generation models. See [Background audio suppression](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-suppression) and [Language model support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). @@ -564,18 +579,19 @@ def recognize( previous-generation models. The `low_latency` parameter causes the models to produce results even more quickly, though the results might be less accurate when the parameter is used. - The parameter is not available for previous-generation `Broadband` and - `Narrowband` models. It is available for most next-generation models. + The parameter is not available for large speech models and + previous-generation `Broadband` and `Narrowband` models. It is available + for most next-generation models. * For a list of next-generation models that support low latency, see [Supported next-generation language models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported). * For more information about the `low_latency` parameter, see [Low latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency). - :param float character_insertion_bias: (optional) For next-generation - models, an indication of whether the service is biased to recognize shorter - or longer strings of characters when developing transcription hypotheses. - By default, the service is optimized to produce the best balance of strings - of different lengths. + :param float character_insertion_bias: (optional) For large speech models + and next-generation models, an indication of whether the service is biased + to recognize shorter or longer strings of characters when developing + transcription hypotheses. By default, the service is optimized to produce + the best balance of strings of different lengths. The default bias is 0.0. The allowable range of values is -1.0 to 1.0. * Negative values bias the service to favor hypotheses with shorter strings of characters. @@ -609,6 +625,7 @@ def recognize( params = { 'model': model, + 'speech_begin_event': speech_begin_event, 'language_customization_id': language_customization_id, 'acoustic_customization_id': acoustic_customization_id, 'base_model_version': base_model_version, @@ -918,31 +935,36 @@ def create_job( fails. **See also:** [Supported audio formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats). - ### Next-generation models - The service supports next-generation `Multimedia` (16 kHz) and `Telephony` (8 - kHz) models for many languages. Next-generation models have higher throughput than - the service's previous generation of `Broadband` and `Narrowband` models. When you - use next-generation models, the service can return transcriptions more quickly and - also provide noticeably better transcription accuracy. - You specify a next-generation model by using the `model` query parameter, as you - do a previous-generation model. Most next-generation models support the - `low_latency` parameter, and all next-generation models support the - `character_insertion_bias` parameter. These parameters are not available with - previous-generation models. - Next-generation models do not support all of the speech recognition parameters - that are available for use with previous-generation models. Next-generation models - do not support the following parameters: + ### Large speech models and Next-generation models + The service supports large speech models and next-generation `Multimedia` (16 + kHz) and `Telephony` (8 kHz) models for many languages. Large speech models and + next-generation models have higher throughput than the service's previous + generation of `Broadband` and `Narrowband` models. When you use large speech + models and next-generation models, the service can return transcriptions more + quickly and also provide noticeably better transcription accuracy. + You specify a large speech model or next-generation model by using the `model` + query parameter, as you do a previous-generation model. Only the next-generation + models support the `low_latency` parameter, and all large speech models and + next-generation models support the `character_insertion_bias` parameter. These + parameters are not available with previous-generation models. + Large speech models and next-generation models do not support all of the speech + recognition parameters that are available for use with previous-generation models. + Next-generation models do not support the following parameters: * `acoustic_customization_id` * `keywords` and `keywords_threshold` * `processing_metrics` and `processing_metrics_interval` * `word_alternatives_threshold` **Important:** Effective **31 July 2023**, all previous-generation models will be removed from the service and the documentation. Most previous-generation models - were deprecated on 15 March 2022. You must migrate to the equivalent - next-generation model by 31 July 2023. For more information, see [Migrating to - next-generation + were deprecated on 15 March 2022. You must migrate to the equivalent large speech + model or next-generation model by 31 July 2023. For more information, see + [Migrating to large speech models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). **See also:** + * [Large speech languages and + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages) + * [Supported features for large speech + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages#models-lsm-supported-features) * [Next-generation languages and models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng) * [Supported features for next-generation @@ -1033,6 +1055,7 @@ def create_job( Specify a value between 0.0 and 1.0. Unless a different customization weight was specified for the custom model when the model was trained, the default value is: + * 0.5 for large speech models * 0.3 for previous-generation models * 0.2 for most next-generation models * 0.1 for next-generation English and Japanese models @@ -1106,9 +1129,10 @@ def create_job( (all dialects) transcription only. See [Smart formatting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-formatting#smart-formatting). - :param int smart_formatting_version: (optional) Smart formatting version is - for next-generation models and that is supported in US English, Brazilian - Portuguese, French and German languages. + :param int smart_formatting_version: (optional) Smart formatting version + for large speech models and next-generation models is supported in US + English, Brazilian Portuguese, French, German, Spanish and French Canadian + languages. :param bool speaker_labels: (optional) If `true`, the response includes labels that identify which words were spoken by which participants in a multi-person exchange. By default, the service returns no speaker labels. @@ -1118,9 +1142,8 @@ def create_job( Australian English, US English, German, Japanese, Korean, and Spanish (both broadband and narrowband models) and UK English (narrowband model) transcription only. - * _For next-generation models,_ the parameter can be used with Czech, - English (Australian, Indian, UK, and US), German, Japanese, Korean, and - Spanish transcription only. + * _For large speech models and next-generation models,_ the parameter can + be used with all available languages. See [Speaker labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-speaker-labels). :param str grammar_name: (optional) The name of a grammar that is to be @@ -1216,8 +1239,8 @@ def create_job( The values increase on a monotonic curve. Specifying one or two decimal places of precision (for example, `0.55`) is typically more than sufficient. - The parameter is supported with all next-generation models and with most - previous-generation models. See [Speech detector + The parameter is supported with all large speech models, next-generation + models and with most previous-generation models. See [Speech detector sensitivity](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-sensitivity) and [Language model support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). @@ -1233,8 +1256,8 @@ def create_job( The values increase on a monotonic curve. Specifying one or two decimal places of precision (for example, `0.55`) is typically more than sufficient. - The parameter is supported with all next-generation models and with most - previous-generation models. See [Background audio + The parameter is supported with all large speech models, next-generation + models and with most previous-generation models. See [Background audio suppression](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-suppression) and [Language model support](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-support). @@ -1245,18 +1268,19 @@ def create_job( previous-generation models. The `low_latency` parameter causes the models to produce results even more quickly, though the results might be less accurate when the parameter is used. - The parameter is not available for previous-generation `Broadband` and - `Narrowband` models. It is available for most next-generation models. + The parameter is not available for large speech models and + previous-generation `Broadband` and `Narrowband` models. It is available + for most next-generation models. * For a list of next-generation models that support low latency, see [Supported next-generation language models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported). * For more information about the `low_latency` parameter, see [Low latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency). - :param float character_insertion_bias: (optional) For next-generation - models, an indication of whether the service is biased to recognize shorter - or longer strings of characters when developing transcription hypotheses. - By default, the service is optimized to produce the best balance of strings - of different lengths. + :param float character_insertion_bias: (optional) For large speech models + and next-generation models, an indication of whether the service is biased + to recognize shorter or longer strings of characters when developing + transcription hypotheses. By default, the service is optimized to produce + the best balance of strings of different lengths. The default bias is 0.0. The allowable range of values is -1.0 to 1.0. * Negative values bias the service to favor hypotheses with shorter strings of characters. @@ -1521,15 +1545,49 @@ def create_language_model( below the limit. **Important:** Effective **31 July 2023**, all previous-generation models will be removed from the service and the documentation. Most previous-generation models - were deprecated on 15 March 2022. You must migrate to the equivalent - next-generation model by 31 July 2023. For more information, see [Migrating to - next-generation + were deprecated on 15 March 2022. You must migrate to the equivalent large speech + model or next-generation model by 31 July 2023. For more information, see + [Migrating to large speech models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). **See also:** * [Create a custom language model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#createModel-language) * [Language support for - customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support). + customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-support) + ### Large speech models and Next-generation models + The service supports large speech models and next-generation `Multimedia` (16 + kHz) and `Telephony` (8 kHz) models for many languages. Large speech models and + next-generation models have higher throughput than the service's previous + generation of `Broadband` and `Narrowband` models. When you use large speech + models and next-generation models, the service can return transcriptions more + quickly and also provide noticeably better transcription accuracy. + You specify a large speech model or next-generation model by using the `model` + query parameter, as you do a previous-generation model. Only the next-generation + models support the `low_latency` parameter, and all large speech models and + next-generation models support the `character_insertion_bias` parameter. These + parameters are not available with previous-generation models. + Large speech models and next-generation models do not support all of the speech + recognition parameters that are available for use with previous-generation models. + Next-generation models do not support the following parameters: + * `acoustic_customization_id` + * `keywords` and `keywords_threshold` + * `processing_metrics` and `processing_metrics_interval` + * `word_alternatives_threshold` + **Important:** Effective **31 July 2023**, all previous-generation models will be + removed from the service and the documentation. Most previous-generation models + were deprecated on 15 March 2022. You must migrate to the equivalent large speech + model or next-generation model by 31 July 2023. For more information, see + [Migrating to large speech + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). + **See also:** + * [Large speech languages and + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages) + * [Supported features for large speech + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-large-speech-languages#models-lsm-supported-features) + * [Next-generation languages and + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng) + * [Supported features for next-generation + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-features). :param str name: A user-defined name for the new custom language model. Use a localized name that matches the language of the custom model. Use a name @@ -1847,14 +1905,16 @@ def train_language_model( * `user` trains the model only on custom words that were added or modified by the user directly. The model is not trained on new words extracted from corpora or grammars. - _For custom models that are based on next-generation models_, the service - ignores the parameter. The words resource contains only custom words that - the user adds or modifies directly, so the parameter is unnecessary. + _For custom models that are based on large speech models and + next-generation models_, the service ignores the `word_type_to_add` + parameter. The words resource contains only custom words that the user adds + or modifies directly, so the parameter is unnecessary. :param float customization_weight: (optional) Specifies a customization weight for the custom language model. The customization weight tells the service how much weight to give to words from the custom language model compared to those from the base model for speech recognition. Specify a value between 0.0 and 1.0. The default value is: + * 0.5 for large speech models * 0.3 for previous-generation models * 0.2 for most next-generation models * 0.1 for next-generation English and Japanese models @@ -2145,6 +2205,9 @@ def add_corpus( additional resources to the custom model or to train the model until the service's analysis of the corpus for the current request completes. Use the [Get a corpus](#getcorpus) method to check the status of the analysis. + _For custom models that are based on large speech models_, the service parses and + extracts word sequences from one or multiple corpora files. The characters help + the service learn and predict character sequences from audio. _For custom models that are based on previous-generation models_, the service auto-populates the model's words resource with words from the corpus that are not found in its base vocabulary. These words are referred to as out-of-vocabulary @@ -2171,11 +2234,11 @@ def add_corpus( model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addCorpus) * [Working with corpora for previous-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingCorpora) - * [Working with corpora for next-generation + * [Working with corpora for large speech models and next-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#workingCorpora-ng) * [Validating a words resource for previous-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel) - * [Validating a words resource for next-generation + * [Validating a words resource for large speech models and next-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#validateModel-ng). :param str customization_id: The customization ID (GUID) of the custom @@ -2543,11 +2606,11 @@ def add_words( model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords) * [Working with custom words for previous-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) - * [Working with custom words for next-generation + * [Working with custom words for large speech models and next-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#workingWords-ng) * [Validating a words resource for previous-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel) - * [Validating a words resource for next-generation + * [Validating a words resource for large speech models and next-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#validateModel-ng). :param str customization_id: The customization ID (GUID) of the custom @@ -2655,11 +2718,11 @@ def add_word( model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords) * [Working with custom words for previous-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) - * [Working with custom words for next-generation + * [Working with custom words for large speech models and next-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#workingWords-ng) * [Validating a words resource for previous-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel) - * [Validating a words resource for next-generation + * [Validating a words resource for large speech models and next-generation models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords-ng#validateModel-ng). :param str customization_id: The customization ID (GUID) of the custom @@ -3238,12 +3301,13 @@ def create_acoustic_model( do not lose any models, but you cannot create any more until your model count is below the limit. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **Important:** Effective **31 July 2023**, all previous-generation models will be removed from the service and the documentation. Most previous-generation models - were deprecated on 15 March 2022. You must migrate to the equivalent - next-generation model by 31 July 2023. For more information, see [Migrating to - next-generation + were deprecated on 15 March 2022. You must migrate to the equivalent large speech + model or next-generation model by 31 July 2023. For more information, see + [Migrating to large speech models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-migrate). **See also:** [Create a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#createModel-acoustic). @@ -3322,7 +3386,8 @@ def list_acoustic_models( all languages. You must use credentials for the instance of the service that owns a model to list information about it. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Listing custom acoustic models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#listModels-acoustic). @@ -3379,7 +3444,8 @@ def get_acoustic_model( Gets information about a specified custom acoustic model. You must use credentials for the instance of the service that owns a model to list information about it. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Listing custom acoustic models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#listModels-acoustic). @@ -3434,7 +3500,8 @@ def delete_acoustic_model( processed. You must use credentials for the instance of the service that owns a model to delete it. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Deleting a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#deleteModel-acoustic). @@ -3518,7 +3585,8 @@ def train_acoustic_model( same version of the same base model, and the custom language model must be fully trained and available. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** * [Train the custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#trainModel-acoustic) @@ -3622,7 +3690,8 @@ def reset_acoustic_model( request completes. You must use credentials for the instance of the service that owns a model to reset it. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Resetting a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#resetModel-acoustic). @@ -3698,7 +3767,8 @@ def upgrade_acoustic_model( the custom acoustic model can be upgraded. Omit the parameter if the custom acoustic model was not trained with a custom language model. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Upgrading a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-custom-upgrade#custom-upgrade-acoustic). @@ -3778,7 +3848,8 @@ def list_audio( to a request to add it to the custom acoustic model. You must use credentials for the instance of the service that owns a model to list its audio resources. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Listing audio resources for a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#listAudio). @@ -3870,7 +3941,8 @@ def add_audio( resource, and it returns the status of the resource. Use a loop to check the status of the audio every few seconds until it becomes `ok`. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Add audio to the custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#addAudio). ### Content types for audio-type resources @@ -4046,7 +4118,8 @@ def get_audio( You must use credentials for the instance of the service that owns a model to list its audio resources. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Listing audio resources for a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#listAudio). @@ -4111,7 +4184,8 @@ def delete_audio( credentials for the instance of the service that owns a model to delete its audio resources. **Note:** Acoustic model customization is supported only for use with - previous-generation models. It is not supported for next-generation models. + previous-generation models. It is not supported for large speech models and + next-generation models. **See also:** [Deleting an audio resource from a custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#deleteAudio). @@ -4239,15 +4313,19 @@ class ModelId(str, Enum): DE_DE_MULTIMEDIA = 'de-DE_Multimedia' DE_DE_NARROWBANDMODEL = 'de-DE_NarrowbandModel' DE_DE_TELEPHONY = 'de-DE_Telephony' + EN_AU = 'en-AU' EN_AU_BROADBANDMODEL = 'en-AU_BroadbandModel' EN_AU_MULTIMEDIA = 'en-AU_Multimedia' EN_AU_NARROWBANDMODEL = 'en-AU_NarrowbandModel' EN_AU_TELEPHONY = 'en-AU_Telephony' + EN_GB = 'en-GB' EN_GB_BROADBANDMODEL = 'en-GB_BroadbandModel' EN_GB_MULTIMEDIA = 'en-GB_Multimedia' EN_GB_NARROWBANDMODEL = 'en-GB_NarrowbandModel' EN_GB_TELEPHONY = 'en-GB_Telephony' + EN_IN = 'en-IN' EN_IN_TELEPHONY = 'en-IN_Telephony' + EN_US = 'en-US' EN_US_BROADBANDMODEL = 'en-US_BroadbandModel' EN_US_MULTIMEDIA = 'en-US_Multimedia' EN_US_NARROWBANDMODEL = 'en-US_NarrowbandModel' @@ -4269,10 +4347,12 @@ class ModelId(str, Enum): ES_MX_NARROWBANDMODEL = 'es-MX_NarrowbandModel' ES_PE_BROADBANDMODEL = 'es-PE_BroadbandModel' ES_PE_NARROWBANDMODEL = 'es-PE_NarrowbandModel' + FR_CA = 'fr-CA' FR_CA_BROADBANDMODEL = 'fr-CA_BroadbandModel' FR_CA_MULTIMEDIA = 'fr-CA_Multimedia' FR_CA_NARROWBANDMODEL = 'fr-CA_NarrowbandModel' FR_CA_TELEPHONY = 'fr-CA_Telephony' + FR_FR = 'fr-FR' FR_FR_BROADBANDMODEL = 'fr-FR_BroadbandModel' FR_FR_MULTIMEDIA = 'fr-FR_Multimedia' FR_FR_NARROWBANDMODEL = 'fr-FR_NarrowbandModel' @@ -4282,6 +4362,7 @@ class ModelId(str, Enum): IT_IT_NARROWBANDMODEL = 'it-IT_NarrowbandModel' IT_IT_MULTIMEDIA = 'it-IT_Multimedia' IT_IT_TELEPHONY = 'it-IT_Telephony' + JA_JP = 'ja-JP' JA_JP_BROADBANDMODEL = 'ja-JP_BroadbandModel' JA_JP_MULTIMEDIA = 'ja-JP_Multimedia' JA_JP_NARROWBANDMODEL = 'ja-JP_NarrowbandModel' @@ -4354,15 +4435,19 @@ class Model(str, Enum): DE_DE_MULTIMEDIA = 'de-DE_Multimedia' DE_DE_NARROWBANDMODEL = 'de-DE_NarrowbandModel' DE_DE_TELEPHONY = 'de-DE_Telephony' + EN_AU = 'en-AU' EN_AU_BROADBANDMODEL = 'en-AU_BroadbandModel' EN_AU_MULTIMEDIA = 'en-AU_Multimedia' EN_AU_NARROWBANDMODEL = 'en-AU_NarrowbandModel' EN_AU_TELEPHONY = 'en-AU_Telephony' + EN_IN = 'en-IN' EN_IN_TELEPHONY = 'en-IN_Telephony' + EN_GB = 'en-GB' EN_GB_BROADBANDMODEL = 'en-GB_BroadbandModel' EN_GB_MULTIMEDIA = 'en-GB_Multimedia' EN_GB_NARROWBANDMODEL = 'en-GB_NarrowbandModel' EN_GB_TELEPHONY = 'en-GB_Telephony' + EN_US = 'en-US' EN_US_BROADBANDMODEL = 'en-US_BroadbandModel' EN_US_MULTIMEDIA = 'en-US_Multimedia' EN_US_NARROWBANDMODEL = 'en-US_NarrowbandModel' @@ -4384,10 +4469,12 @@ class Model(str, Enum): ES_MX_NARROWBANDMODEL = 'es-MX_NarrowbandModel' ES_PE_BROADBANDMODEL = 'es-PE_BroadbandModel' ES_PE_NARROWBANDMODEL = 'es-PE_NarrowbandModel' + FR_CA = 'fr-CA' FR_CA_BROADBANDMODEL = 'fr-CA_BroadbandModel' FR_CA_MULTIMEDIA = 'fr-CA_Multimedia' FR_CA_NARROWBANDMODEL = 'fr-CA_NarrowbandModel' FR_CA_TELEPHONY = 'fr-CA_Telephony' + FR_FR = 'fr-FR' FR_FR_BROADBANDMODEL = 'fr-FR_BroadbandModel' FR_FR_MULTIMEDIA = 'fr-FR_Multimedia' FR_FR_NARROWBANDMODEL = 'fr-FR_NarrowbandModel' @@ -4397,6 +4484,7 @@ class Model(str, Enum): IT_IT_NARROWBANDMODEL = 'it-IT_NarrowbandModel' IT_IT_MULTIMEDIA = 'it-IT_Multimedia' IT_IT_TELEPHONY = 'it-IT_Telephony' + JA_JP = 'ja-JP' JA_JP_BROADBANDMODEL = 'ja-JP_BroadbandModel' JA_JP_MULTIMEDIA = 'ja-JP_Multimedia' JA_JP_NARROWBANDMODEL = 'ja-JP_NarrowbandModel' @@ -4469,15 +4557,19 @@ class Model(str, Enum): DE_DE_MULTIMEDIA = 'de-DE_Multimedia' DE_DE_NARROWBANDMODEL = 'de-DE_NarrowbandModel' DE_DE_TELEPHONY = 'de-DE_Telephony' + EN_AU = 'en-AU' EN_AU_BROADBANDMODEL = 'en-AU_BroadbandModel' EN_AU_MULTIMEDIA = 'en-AU_Multimedia' EN_AU_NARROWBANDMODEL = 'en-AU_NarrowbandModel' EN_AU_TELEPHONY = 'en-AU_Telephony' + EN_IN = 'en-IN' EN_IN_TELEPHONY = 'en-IN_Telephony' + EN_GB = 'en-GB' EN_GB_BROADBANDMODEL = 'en-GB_BroadbandModel' EN_GB_MULTIMEDIA = 'en-GB_Multimedia' EN_GB_NARROWBANDMODEL = 'en-GB_NarrowbandModel' EN_GB_TELEPHONY = 'en-GB_Telephony' + EN_US = 'en-US' EN_US_BROADBANDMODEL = 'en-US_BroadbandModel' EN_US_MULTIMEDIA = 'en-US_Multimedia' EN_US_NARROWBANDMODEL = 'en-US_NarrowbandModel' @@ -4499,10 +4591,12 @@ class Model(str, Enum): ES_MX_NARROWBANDMODEL = 'es-MX_NarrowbandModel' ES_PE_BROADBANDMODEL = 'es-PE_BroadbandModel' ES_PE_NARROWBANDMODEL = 'es-PE_NarrowbandModel' + FR_CA = 'fr-CA' FR_CA_BROADBANDMODEL = 'fr-CA_BroadbandModel' FR_CA_MULTIMEDIA = 'fr-CA_Multimedia' FR_CA_NARROWBANDMODEL = 'fr-CA_NarrowbandModel' FR_CA_TELEPHONY = 'fr-CA_Telephony' + FR_FR = 'fr-FR' FR_FR_BROADBANDMODEL = 'fr-FR_BroadbandModel' FR_FR_MULTIMEDIA = 'fr-FR_Multimedia' FR_FR_NARROWBANDMODEL = 'fr-FR_NarrowbandModel' @@ -4512,6 +4606,7 @@ class Model(str, Enum): IT_IT_NARROWBANDMODEL = 'it-IT_NarrowbandModel' IT_IT_MULTIMEDIA = 'it-IT_Multimedia' IT_IT_TELEPHONY = 'it-IT_Telephony' + JA_JP = 'ja-JP' JA_JP_BROADBANDMODEL = 'ja-JP_BroadbandModel' JA_JP_MULTIMEDIA = 'ja-JP_Multimedia' JA_JP_NARROWBANDMODEL = 'ja-JP_NarrowbandModel' @@ -4621,9 +4716,10 @@ class WordTypeToAdd(str, Enum): * `user` trains the model only on custom words that were added or modified by the user directly. The model is not trained on new words extracted from corpora or grammars. - _For custom models that are based on next-generation models_, the service ignores - the parameter. The words resource contains only custom words that the user adds or - modifies directly, so the parameter is unnecessary. + _For custom models that are based on large speech models and next-generation + models_, the service ignores the `word_type_to_add` parameter. The words resource + contains only custom words that the user adds or modifies directly, so the + parameter is unnecessary. """ ALL = 'all' @@ -6167,9 +6263,9 @@ class Corpus: :param str name: The name of the corpus. :param int total_words: The total number of words in the corpus. The value is `0` while the corpus is being processed. - :param int out_of_vocabulary_words: _For custom models that are based on - previous-generation models_, the number of OOV words extracted from the corpus. - The value is `0` while the corpus is being processed. + :param int out_of_vocabulary_words: _For custom models that are based on large + speech models and previous-generation models_, the number of OOV words extracted + from the corpus. The value is `0` while the corpus is being processed. _For custom models that are based on next-generation models_, no OOV words are extracted from corpora, so the value is always `0`. :param str status: The status of the corpus: @@ -6200,8 +6296,9 @@ def __init__( :param int total_words: The total number of words in the corpus. The value is `0` while the corpus is being processed. :param int out_of_vocabulary_words: _For custom models that are based on - previous-generation models_, the number of OOV words extracted from the - corpus. The value is `0` while the corpus is being processed. + large speech models and previous-generation models_, the number of OOV + words extracted from the corpus. The value is `0` while the corpus is being + processed. _For custom models that are based on next-generation models_, no OOV words are extracted from corpora, so the value is always `0`. :param str status: The status of the corpus: diff --git a/ibm_watson/speech_to_text_v1_adapter.py b/ibm_watson/speech_to_text_v1_adapter.py index fedc5af5..67820be8 100644 --- a/ibm_watson/speech_to_text_v1_adapter.py +++ b/ibm_watson/speech_to_text_v1_adapter.py @@ -1,6 +1,6 @@ # coding: utf-8 -# (C) Copyright IBM Corp. 2018, 2021. +# (C) Copyright IBM Corp. 2018, 2024. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ def recognize_using_websocket(self, customization_weight=None, base_model_version=None, inactivity_timeout=None, - interim_results=None, keywords=None, keywords_threshold=None, max_alternatives=None, @@ -55,7 +54,6 @@ def recognize_using_websocket(self, split_transcript_at_phrase_end=None, speech_detector_sensitivity=None, background_audio_suppression=None, - low_latency=None, character_insertion_bias=None, **kwargs): """ @@ -271,22 +269,6 @@ def recognize_using_websocket(self, * 1.0 suppresses all audio (no audio is transcribed). The values increase on a monotonic curve. See [Background audio suppression](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-detection#detection-parameters-suppression). - :param bool low_latency: (optional) If `true` for next-generation - `Multimedia` and `Telephony` models that support low latency, directs the - service to produce results even more quickly than it usually does. - Next-generation models produce transcription results faster than - previous-generation models. The `low_latency` parameter causes the models - to produce results even more quickly, though the results might be less - accurate when the parameter is used. - **Note:** The parameter is beta functionality. It is not available for - previous-generation `Broadband` and `Narrowband` models. It is available - only for some next-generation models. - * For a list of next-generation models that support low latency, see - [Supported language - models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models-ng#models-ng-supported) - for next-generation models. - * For more information about the `low_latency` parameter, see [Low - latency](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-interim#low-latency). :param float character_insertion_bias: (optional) For next-generation `Multimedia` and `Telephony` models, an indication of whether the service is biased to recognize shorter or longer strings of characters when @@ -355,7 +337,6 @@ def recognize_using_websocket(self, 'customization_weight': customization_weight, 'content_type': content_type, 'inactivity_timeout': inactivity_timeout, - 'interim_results': interim_results, 'keywords': keywords, 'keywords_threshold': keywords_threshold, 'max_alternatives': max_alternatives, @@ -375,7 +356,6 @@ def recognize_using_websocket(self, 'split_transcript_at_phrase_end': split_transcript_at_phrase_end, 'speech_detector_sensitivity': speech_detector_sensitivity, 'background_audio_suppression': background_audio_suppression, - 'low_latency': low_latency, 'character_insertion_bias': character_insertion_bias } options = {k: v for k, v in options.items() if v is not None} diff --git a/ibm_watson/version.py b/ibm_watson/version.py index 49920925..2d63b74a 100644 --- a/ibm_watson/version.py +++ b/ibm_watson/version.py @@ -1 +1 @@ -__version__ = '8.0.1' +__version__ = '8.1.0' diff --git a/ibm_watson/websocket/recognize_listener.py b/ibm_watson/websocket/recognize_listener.py index 43eb7961..041bcf69 100644 --- a/ibm_watson/websocket/recognize_listener.py +++ b/ibm_watson/websocket/recognize_listener.py @@ -196,16 +196,15 @@ def on_data(self, ws, message, message_type, fin): # set of transcriptions and send them to the appropriate callbacks. results = json_object.get('results') if results: - if (self.options.get('interim_results') is True): - b_final = (results[0].get('final') is True) - alternatives = results[0].get('alternatives') - if alternatives: - hypothesis = alternatives[0].get('transcript') - transcripts = self.extract_transcripts(alternatives) - if b_final: - self.callback.on_transcription(transcripts) - if hypothesis: - self.callback.on_hypothesis(hypothesis) + b_final = (results[0].get('final') is True) + alternatives = results[0].get('alternatives') + if alternatives: + hypothesis = alternatives[0].get('transcript') + transcripts = self.extract_transcripts(alternatives) + if b_final: + self.callback.on_transcription(transcripts) + if hypothesis: + self.callback.on_hypothesis(hypothesis) else: final_transcript = [] for result in results: diff --git a/setup.py b/setup.py index 06d519f8..e34bb44b 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ from setuptools import setup from os import path -__version__ = '8.0.1' +__version__ = '8.1.0' # read contents of README file this_directory = path.abspath(path.dirname(__file__)) diff --git a/test/integration/test_speech_to_text_v1.py b/test/integration/test_speech_to_text_v1.py index 808a8847..1d41df96 100644 --- a/test/integration/test_speech_to_text_v1.py +++ b/test/integration/test_speech_to_text_v1.py @@ -118,83 +118,6 @@ def on_data(self, data): assert test_callback.data['results'][0]['alternatives'][0] ['transcript'] == 'thunderstorms could produce large hail isolated tornadoes and heavy rain ' - def test_on_transcription_interim_results_false(self): - - class MyRecognizeCallback(RecognizeCallback): - - def __init__(self): - RecognizeCallback.__init__(self) - self.error = None - self.transcript = None - - def on_error(self, error): - self.error = error - - def on_transcription(self, transcript): - self.transcript = transcript - - test_callback = MyRecognizeCallback() - with open(os.path.join(os.path.dirname(__file__), '../../resources/speech_with_pause.wav'), 'rb') as audio_file: - audio_source = AudioSource(audio_file, False) - self.speech_to_text.recognize_using_websocket(audio_source, "audio/wav", test_callback, model="en-US_Telephony", - interim_results=False, low_latency=False) - assert test_callback.error is None - assert test_callback.transcript is not None - assert test_callback.transcript[0][0]['transcript'] in ['isolated tornadoes ', 'isolated tornados '] - assert test_callback.transcript[1][0]['transcript'] == 'and heavy rain ' - - def test_on_transcription_interim_results_true(self): - - class MyRecognizeCallback(RecognizeCallback): - - def __init__(self): - RecognizeCallback.__init__(self) - self.error = None - self.transcript = None - - def on_error(self, error): - self.error = error - - def on_transcription(self, transcript): - self.transcript = transcript - assert transcript[0]['confidence'] is not None - assert transcript[0]['transcript'] is not None - - test_callback = MyRecognizeCallback() - with open(os.path.join(os.path.dirname(__file__), '../../resources/speech_with_pause.wav'), 'rb') as audio_file: - audio_source = AudioSource(audio_file, False) - self.speech_to_text.recognize_using_websocket(audio_source, "audio/wav", test_callback, model="en-US_Telephony", - interim_results=True, low_latency=True) - assert test_callback.error is None - assert test_callback.transcript is not None - assert test_callback.transcript[0]['transcript'] == 'and heavy rain ' - - def test_on_transcription_interim_results_true_low_latency_false(self): - - class MyRecognizeCallback(RecognizeCallback): - - def __init__(self): - RecognizeCallback.__init__(self) - self.error = None - self.transcript = None - - def on_error(self, error): - self.error = error - - def on_transcription(self, transcript): - self.transcript = transcript - assert transcript[0]['confidence'] is not None - assert transcript[0]['transcript'] is not None - - test_callback = MyRecognizeCallback() - with open(os.path.join(os.path.dirname(__file__), '../../resources/speech_with_pause.wav'), 'rb') as audio_file: - audio_source = AudioSource(audio_file, False) - self.speech_to_text.recognize_using_websocket(audio_source, "audio/wav", test_callback, model="en-US_Telephony", - interim_results=True, low_latency=False) - assert test_callback.error is None - assert test_callback.transcript is not None - assert test_callback.transcript[0]['transcript'] == 'and heavy rain ' - def test_custom_grammars(self): customization_id = None for custom_model in self.custom_models.get('customizations'): diff --git a/test/unit/test_discovery_v2.py b/test/unit/test_discovery_v2.py index 3b1008aa..4a8bf169 100644 --- a/test/unit/test_discovery_v2.py +++ b/test/unit/test_discovery_v2.py @@ -85,7 +85,7 @@ def test_list_projects_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects') - mock_response = '{"projects": [{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16}]}' + mock_response = '{"projects": [{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16}]}' responses.add( responses.GET, url, @@ -117,7 +117,7 @@ def test_list_projects_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects') - mock_response = '{"projects": [{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16}]}' + mock_response = '{"projects": [{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16}]}' responses.add( responses.GET, url, @@ -156,7 +156,7 @@ def test_create_project_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.POST, url, @@ -200,7 +200,7 @@ def test_create_project_all_params(self): # Set up parameter values name = 'testString' - type = 'document_retrieval' + type = 'intelligent_document_processing' default_query_parameters = default_query_params_model # Invoke method @@ -217,7 +217,7 @@ def test_create_project_all_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['name'] == 'testString' - assert req_body['type'] == 'document_retrieval' + assert req_body['type'] == 'intelligent_document_processing' assert req_body['default_query_parameters'] == default_query_params_model def test_create_project_all_params_with_retries(self): @@ -236,7 +236,7 @@ def test_create_project_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.POST, url, @@ -280,7 +280,7 @@ def test_create_project_value_error(self): # Set up parameter values name = 'testString' - type = 'document_retrieval' + type = 'intelligent_document_processing' default_query_parameters = default_query_params_model # Pass in all but one required param and check for a ValueError @@ -315,7 +315,7 @@ def test_get_project_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects/testString') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.GET, url, @@ -353,7 +353,7 @@ def test_get_project_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects/testString') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.GET, url, @@ -396,7 +396,7 @@ def test_update_project_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects/testString') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.POST, url, @@ -439,7 +439,7 @@ def test_update_project_required_params(self): """ # Set up mock url = preprocess_url('/v2/projects/testString') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.POST, url, @@ -477,7 +477,7 @@ def test_update_project_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects/testString') - mock_response = '{"project_id": "project_id", "name": "name", "type": "document_retrieval", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' + mock_response = '{"project_id": "project_id", "name": "name", "type": "intelligent_document_processing", "relevancy_training_status": {"data_updated": "data_updated", "total_examples": 14, "sufficient_label_diversity": true, "processing": true, "minimum_examples_added": true, "successfully_trained": "successfully_trained", "available": false, "notices": 7, "minimum_queries_added": false}, "collection_count": 16, "default_query_parameters": {"collection_ids": ["collection_ids"], "passages": {"enabled": false, "count": 5, "fields": ["fields"], "characters": 10, "per_document": true, "max_per_document": 16}, "table_results": {"enabled": false, "count": 5, "per_document": 0}, "aggregation": "aggregation", "suggested_refinements": {"enabled": false, "count": 5}, "spelling_suggestions": true, "highlight": false, "count": 5, "sort": "sort", "return": ["return_"]}}' responses.add( responses.POST, url, @@ -812,7 +812,7 @@ def test_create_collection_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects/testString/collections') - mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' + mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "ocr_enabled": false, "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' responses.add( responses.POST, url, @@ -831,6 +831,7 @@ def test_create_collection_all_params(self): name = 'testString' description = 'testString' language = 'en' + ocr_enabled = False enrichments = [collection_enrichment_model] # Invoke method @@ -839,6 +840,7 @@ def test_create_collection_all_params(self): name, description=description, language=language, + ocr_enabled=ocr_enabled, enrichments=enrichments, headers={}, ) @@ -851,6 +853,7 @@ def test_create_collection_all_params(self): assert req_body['name'] == 'testString' assert req_body['description'] == 'testString' assert req_body['language'] == 'en' + assert req_body['ocr_enabled'] == False assert req_body['enrichments'] == [collection_enrichment_model] def test_create_collection_all_params_with_retries(self): @@ -869,7 +872,7 @@ def test_create_collection_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects/testString/collections') - mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' + mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "ocr_enabled": false, "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' responses.add( responses.POST, url, @@ -888,6 +891,7 @@ def test_create_collection_value_error(self): name = 'testString' description = 'testString' language = 'en' + ocr_enabled = False enrichments = [collection_enrichment_model] # Pass in all but one required param and check for a ValueError @@ -922,7 +926,7 @@ def test_get_collection_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects/testString/collections/testString') - mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' + mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "ocr_enabled": false, "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' responses.add( responses.GET, url, @@ -962,7 +966,7 @@ def test_get_collection_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects/testString/collections/testString') - mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' + mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "ocr_enabled": false, "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' responses.add( responses.GET, url, @@ -1007,7 +1011,7 @@ def test_update_collection_all_params(self): """ # Set up mock url = preprocess_url('/v2/projects/testString/collections/testString') - mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' + mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "ocr_enabled": false, "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' responses.add( responses.POST, url, @@ -1026,6 +1030,7 @@ def test_update_collection_all_params(self): collection_id = 'testString' name = 'testString' description = 'testString' + ocr_enabled = False enrichments = [collection_enrichment_model] # Invoke method @@ -1034,6 +1039,7 @@ def test_update_collection_all_params(self): collection_id, name=name, description=description, + ocr_enabled=ocr_enabled, enrichments=enrichments, headers={}, ) @@ -1045,6 +1051,7 @@ def test_update_collection_all_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['name'] == 'testString' assert req_body['description'] == 'testString' + assert req_body['ocr_enabled'] == False assert req_body['enrichments'] == [collection_enrichment_model] def test_update_collection_all_params_with_retries(self): @@ -1063,7 +1070,7 @@ def test_update_collection_value_error(self): """ # Set up mock url = preprocess_url('/v2/projects/testString/collections/testString') - mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' + mock_response = '{"collection_id": "collection_id", "name": "name", "description": "description", "created": "2019-01-01T12:00:00.000Z", "language": "en", "ocr_enabled": false, "enrichments": [{"enrichment_id": "enrichment_id", "fields": ["fields"]}], "smart_document_understanding": {"enabled": false, "model": "custom"}}' responses.add( responses.POST, url, @@ -1082,6 +1089,7 @@ def test_update_collection_value_error(self): collection_id = 'testString' name = 'testString' description = 'testString' + ocr_enabled = False enrichments = [collection_enrichment_model] # Pass in all but one required param and check for a ValueError @@ -5776,6 +5784,7 @@ def test_collection_details_serialization(self): collection_details_model_json['name'] = 'testString' collection_details_model_json['description'] = 'testString' collection_details_model_json['language'] = 'en' + collection_details_model_json['ocr_enabled'] = False collection_details_model_json['enrichments'] = [collection_enrichment_model] # Construct a model instance of CollectionDetails by calling from_dict on the json representation @@ -7135,7 +7144,7 @@ def test_list_projects_response_serialization(self): project_list_details_model = {} # ProjectListDetails project_list_details_model['name'] = 'testString' - project_list_details_model['type'] = 'document_retrieval' + project_list_details_model['type'] = 'intelligent_document_processing' # Construct a json representation of a ListProjectsResponse model list_projects_response_model_json = {} @@ -7327,7 +7336,7 @@ def test_project_details_serialization(self): # Construct a json representation of a ProjectDetails model project_details_model_json = {} project_details_model_json['name'] = 'testString' - project_details_model_json['type'] = 'document_retrieval' + project_details_model_json['type'] = 'intelligent_document_processing' project_details_model_json['default_query_parameters'] = default_query_params_model # Construct a model instance of ProjectDetails by calling from_dict on the json representation @@ -7359,7 +7368,7 @@ def test_project_list_details_serialization(self): # Construct a json representation of a ProjectListDetails model project_list_details_model_json = {} project_list_details_model_json['name'] = 'testString' - project_list_details_model_json['type'] = 'document_retrieval' + project_list_details_model_json['type'] = 'intelligent_document_processing' # Construct a model instance of ProjectListDetails by calling from_dict on the json representation project_list_details_model = ProjectListDetails.from_dict(project_list_details_model_json) diff --git a/test/unit/test_speech_to_text_v1.py b/test/unit/test_speech_to_text_v1.py index 30475296..781732cc 100644 --- a/test/unit/test_speech_to_text_v1.py +++ b/test/unit/test_speech_to_text_v1.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2015, 2024. +# (C) Copyright IBM Corp. 2024. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -224,6 +224,7 @@ def test_recognize_all_params(self): audio = io.BytesIO(b'This is a mock file.').getvalue() content_type = 'application/octet-stream' model = 'en-US_BroadbandModel' + speech_begin_event = False language_customization_id = 'testString' acoustic_customization_id = 'testString' base_model_version = 'testString' @@ -254,6 +255,7 @@ def test_recognize_all_params(self): audio, content_type=content_type, model=model, + speech_begin_event=speech_begin_event, language_customization_id=language_customization_id, acoustic_customization_id=acoustic_customization_id, base_model_version=base_model_version, @@ -288,6 +290,7 @@ def test_recognize_all_params(self): query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'model={}'.format(model) in query_string + assert 'speech_begin_event={}'.format('true' if speech_begin_event else 'false') in query_string assert 'language_customization_id={}'.format(language_customization_id) in query_string assert 'acoustic_customization_id={}'.format(acoustic_customization_id) in query_string assert 'base_model_version={}'.format(base_model_version) in query_string