phonexia-enhanced-speech-to-text-built-on-whisper-client 1.2.3__tar.gz → 1.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phonexia-enhanced-speech-to-text-built-on-whisper-client
3
- Version: 1.2.3
3
+ Version: 1.2.5
4
4
  Summary: Client for communication with Phonexia Enhanced Speech To Text Built On Whisper microservice.
5
5
  Keywords: grpc,transcription,STT,ASR,speech to text,speech,language,microservice
6
6
  Author: Phonexia
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Dist: grpcio (>=1.54.0,<2.0.0)
16
- Requires-Dist: phonexia-grpc (>=1.0.0,<2.0.0)
16
+ Requires-Dist: phonexia-grpc (>=2.0.0,<3.0.0)
17
17
  Project-URL: Homepage, https://phonexia.com
18
18
  Project-URL: Issues, https://phonexia.atlassian.net/servicedesk/customer/portal/15/group/20/create/40
19
19
  Project-URL: protofiles, https://github.com/phonexia/protofiles
@@ -1,4 +1,5 @@
1
1
  import argparse
2
+ import json
2
3
  import logging
3
4
  import os
4
5
  from enum import Enum
@@ -6,6 +7,8 @@ from typing import Iterator, Optional
6
7
 
7
8
  import google.protobuf.duration_pb2
8
9
  import grpc
10
+ from google.protobuf.json_format import MessageToDict
11
+
9
12
  import phonexia.grpc.technologies.enhanced_speech_to_text_built_on_whisper.v1.enhanced_speech_to_text_built_on_whisper_pb2_grpc as stt_grpc
10
13
  from phonexia.grpc.common.core_pb2 import Audio, TimeRange
11
14
  from phonexia.grpc.technologies.enhanced_speech_to_text_built_on_whisper.v1.enhanced_speech_to_text_built_on_whisper_pb2 import (
@@ -26,7 +29,7 @@ class Task(Enum):
26
29
  return self.value
27
30
 
28
31
 
29
- def time_to_duration(time: float) -> google.protobuf.duration_pb2.Duration | None:
32
+ def time_to_duration(time: float) -> Optional[google.protobuf.duration_pb2.Duration]:
30
33
  if time is None:
31
34
  return None
32
35
  duration = google.protobuf.duration_pb2.Duration()
@@ -111,37 +114,32 @@ def transcribe(
111
114
  else:
112
115
  raise RuntimeError("Unknown task")
113
116
 
114
- warning_message = []
117
+ info_message = []
118
+ response_dict = None
115
119
  for _response in response:
120
+ if not response_dict:
121
+ response_dict = MessageToDict(_response)
122
+ else:
123
+ response_dict["result"]["oneBest"]["segments"] += \
124
+ MessageToDict(_response)["result"]["oneBest"]["segments"] # fmt: skip
125
+
116
126
  for segment in _response.result.one_best.segments:
117
- print(
118
- f"[{segment.start_time.ToJsonString()} -> {segment.end_time.ToJsonString()} "
119
- + (
120
- f"{segment.language}"
121
- if task == Task.transcribe
122
- else f"{segment.source_language} -> {segment.language}"
123
- )
124
- + f"] {segment.text}"
125
- )
126
127
  if segment.source_language != segment.detected_source_language:
127
- warning_message.append(
128
- f"Language '{segment.detected_source_language}' was detected, but the license does not support this language. "
129
- f"Instead the segment was {'transcribed' if task == Task.transcribe else 'translated'} with the "
128
+ info_message.append(
129
+ f"Language '{segment.detected_source_language}' was detected in the audio, but instead "
130
+ f"the segment was {'transcribed' if task == Task.transcribe else 'translated'} with the "
130
131
  + (
131
132
  f"closest available source language '{segment.source_language}'"
132
133
  if language is None
133
- else f"language '{language}' that was enforced by argument '--language'"
134
+ else f"language '{language}' that was enforced by the '--language' argument"
134
135
  )
135
- + ". For more info on this problem don't hesitate to contact Phonexia."
136
136
  )
137
- if _response.HasField("processed_audio_length"):
138
- print(f"Processed audio length: {_response.processed_audio_length.ToJsonString()}")
139
-
140
- warning_message = set(warning_message)
141
- if len(warning_message) > 0:
142
- print()
143
- for warning in warning_message:
144
- print(f"WARNING: {warning}")
137
+
138
+ print(json.dumps(response_dict, indent=2, ensure_ascii=False))
139
+ info_message = set(info_message)
140
+ if len(info_message) > 0:
141
+ for msg in info_message:
142
+ logging.info(msg)
145
143
 
146
144
 
147
145
  def main():
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "phonexia-enhanced-speech-to-text-built-on-whisper-client"
3
- version = "1.2.3"
3
+ version = "1.2.5"
4
4
  description = "Client for communication with Phonexia Enhanced Speech To Text Built On Whisper microservice."
5
5
  readme = "pypi-README.md"
6
6
  keywords = ["grpc", "transcription", "STT", "ASR", "speech to text", "speech", "language", "microservice"]
@@ -17,7 +17,7 @@ enhanced_speech_to_text_built_on_whisper_client = 'phonexia_enhanced_speech_to_t
17
17
  [tool.poetry.dependencies]
18
18
  python = ">=3.8,<4.0"
19
19
  grpcio = "^1.54.0"
20
- phonexia-grpc = {version="^1.0.0", source="pypi"}
20
+ phonexia-grpc = {version="^2.0.0", source="pypi"}
21
21
 
22
22
  [tool.poetry.group.dev.dependencies]
23
23
  pytest = "^8.0.0"
@@ -50,7 +50,7 @@ preview = true
50
50
  target-version = "py38"
51
51
  line-length = 100
52
52
  fix = true
53
- select = [
53
+ lint.select = [
54
54
  # flake8-2020
55
55
  "YTT",
56
56
  # flake8-bandit
@@ -82,7 +82,7 @@ select = [
82
82
  # tryceratops
83
83
  "TRY",
84
84
  ]
85
- ignore = [
85
+ lint.ignore = [
86
86
  # LineTooLong
87
87
  "E501",
88
88
  # DoNotAssignLambda