in infra-as-code/modules/ingest-pipeline/cf-audio-redaction/audio_redaction.py [0:0]
def redact_text(self, data):
data[0]['dlp'] = []
client = dlp.DlpServiceClient()
inspect_config = dlp.InspectConfig(
info_types=
[
dlp.InfoType(name="PERSON_NAME"),
dlp.InfoType(name="PHONE_NUMBER"),
dlp.InfoType(name="ORGANIZATION_NAME"),
dlp.InfoType(name="FIRST_NAME"),
dlp.InfoType(name="LAST_NAME"),
dlp.InfoType(name="EMAIL_ADDRESS"),
dlp.InfoType(name="DATE_OF_BIRTH"),
dlp.InfoType(name="EMAIL_ADDRESS"),
dlp.InfoType(name="US_SOCIAL_SECURITY_NUMBER"),
dlp.InfoType(name="STREET_ADDRESS")
],
include_quote=True
)
item = dlp.ContentItem(
value=data[0]['transcript'],
)
request = dlp.InspectContentRequest(
parent=f"projects/{self.project_id}", # Correct parent construction
inspect_config=inspect_config,
item=item,
)
response = client.inspect_content(request=request)
print(response)
if response.result.findings:
for finding in response.result.findings:
try:
if finding.quote:
print("Quote: {}".format(finding.quote))
data[0]['dlp'].append(finding.quote)
except AttributeError:
pass
else:
print("No findings.")
return data