0

I am facing the KeyError: 'confidence' while trying to export the redacted content to Word docx using python tscribe module.

File "transcribe_script.py", line 124, in export_files
    tscribe.write(json_file_path, format="docx", save_as= save_as_path)
  File "C:\Users\Shufyan\Anaconda3\envs\upwork\lib\site-packages\tscribe\__init__.py", line 597, in write
    df = decode_transcript(data)
  File "C:\Users\Shufyan\Anaconda3\envs\upwork\lib\site-packages\tscribe\__init__.py", line 167, in decode_transcript
    result = sorted(
  File "C:\Users\Shufyan\Anaconda3\envs\upwork\lib\site-packages\tscribe\__init__.py", line 168, in <lambda>
    word_result[-1]["alternatives"], key=lambda x: x["confidence"]
KeyError: 'confidence'

Here's the code:

if json_content['results']['transcripts'][0]['transcript'] != "" :
    json_file_path = os.path.join(self.output_path, obj.key)
    save_as_path = os.path.join(self.output_path, obj_name +'.docx')
    tscribe.write(json_file_path, format="docx", save_as= save_as_path)
Shufyan
  • 21
  • 5
  • Hi, please post the code you currently have. – Peter Sutton Oct 02 '20 at 21:18
  • Hi Peter, the code is fairly simple: `if json_content['results']['transcripts'][0]['transcript'] != "" : json_file_path = os.path.join(self.output_path, obj.key) save_as_path = os.path.join(self.output_path, obj_name +'.docx') tscribe.write(json_file_path, format="docx", save_as= save_as_path)` It only fails with the error I mentioned above, when the transcript contain redacted data i.e. [PII] as per AWS. It works fine with the data without redacted value. – Shufyan Oct 03 '20 at 21:00
  • Hi again, please edit your question to include the code. – Peter Sutton Oct 04 '20 at 14:18

0 Answers0