you can just use a dictionary or an array and do something like this # Define a dictionary to map speaker tags to actual names speaker_names = { "A": "Liam", "B": "John", "C": "Arbel" # Add more mappings as needed } # Assuming transcript.utterances is a list of objects with attributes 'speaker' and 'text' for utterance in transcript.utterances: # Map speaker tag to name speaker_tag = utterance.speaker speaker_name = speaker_names.get(speaker_tag, "Unknown Speaker") print(f"{speaker_name}: {utterance.text}")
great tutorial!
Thanks for sharing. Top!
The tricky part is id by actual name. Any tips on that?
you can just use a dictionary or an array and do something like this
# Define a dictionary to map speaker tags to actual names
speaker_names = {
"A": "Liam",
"B": "John",
"C": "Arbel"
# Add more mappings as needed
}
# Assuming transcript.utterances is a list of objects with attributes 'speaker' and 'text'
for utterance in transcript.utterances:
# Map speaker tag to name
speaker_tag = utterance.speaker
speaker_name = speaker_names.get(speaker_tag, "Unknown Speaker")
print(f"{speaker_name}: {utterance.text}")
Can it identify who is the agent and who is the customer?