snoack321
Member
Is there a proscan add on or other software you can add to convert audio files to text to stream host on web server? Thanks in advance.
What software did you use for this xicarusx?So I saw this post the other day and decided to give it a shot myself. Yea its not perfect, and its can be weird at times, but its kinda fun.
What software did you use for this xicarusx?
import asyncio
from deepgram import Deepgram
deepgram_api_key = '' # insert your api key here
path_to_file = '/home/pi/audio/Litchfield_26_2022_07_29_13_23_26.mp3' # Absolute path to file
file_mime_type = 'audio/mp3' # Mimetype of the file Examples: 'audio/wav' 'audio/mp3'
async def main():
# Initializes the Deepgram SDK
dg_client = Deepgram(deepgram_api_key)
with open(PATH_TO_FILE, 'rb') as audio:
source = {'buffer': audio, 'mimetype': file_mime_type}
# settings options to include puncuation phonecall model and enhanced tier
options = {'punctuate': True, 'language': 'en', 'model': 'phonecall', 'tier': 'enhanced'}
response = await dg_client.transcription.prerecorded(source, options)
transcript = response["results"]["channels"][0]["alternatives"][0]["transcript"]
if transcript:
print(transcript)
else:
print("No Transcription")
asyncio.run(main())
How are you deciphering?
# Grab load transcript from json array to variable and make it lowercase.
transcript = response["results"]["channels"][0]["alternatives"][0]["transcript"].lower()
# create a variable to hold the action we find.
action = ""
if "tree down" in transcript or "trees down" in transcript:
action = "Tree down"
elif "alarm activation" in transcript or "fire alarm" in transcript or "brush fire" in transcript or "structure fire" in transcript or "vehicle fire" in transcript or "unnkown type of fire" in transcript:
if "fire alarm" in transcript or "alarm activation" in transcript:
action = "Automatic Fire Alarm"
elif "brush fire" in transcript:
action = "Brush Fire"
elif "vehicle fire" in transcript:
action = "Vehicle Fire"
elif "structure fire" in transcript:
action = "Structure Fire"
else:
action = "Unknown type of fire"
else:
action = "Unknown"
# find road, street, avenue, parkway, way, drive, lane, route, and get info from it
if "route" in transcript:
pre = transcript.split("route")[0]
post = transcript.split("route")[1]
address = post.split(".")
address = address[0].lstrip()
address_split = address.split()
# Since route is usually called by number "County Route 64" change any text numbers to integers
address = text2int(address)
elif "street" in transcript:
if "street," in transcript:
transcript = transcript.replace("street,", "street.")
pre = transcript.split("street")[0]
post = transcript.split("street")[1]
# Check if the second word from last is a direction "North Main Street"
if "north" in pre.split()[-2]:
address = "N." + " " + pre.split()[-1].lstrip().replace(" ", " ").capitalize()
elif "south" in pre.split()[-2]:
address = "S." + " " + pre.split()[-1].lstrip().replace(" ", " ").capitalize()
elif "east" in pre.split()[-2]:
address = "E." + " " + pre.split()[-1].lstrip().replace(" ", " ").capitalize()
elif "west" in pre.split()[-2]:
address = "W." + " " + pre.split()[-1].lstrip().replace(" ", " ").capitalize()
# Check if the third word from last is a direction "North Hammond Dam Street"
elif "north" in pre.split()[-3]:
address = "N." + " " + pre.split()[-2].lstrip().replace(" ", " ").capitalize()
elif "south" in pre.split()[-3]:
address = "S." + " " + pre.split()[-2].lstrip().replace(" ", " ").capitalize()
elif "east" in pre.split()[-3]:
address = "E." + " " + pre.split()[-2].lstrip().replace(" ", " ").capitalize()
elif "west" in pre.split()[-3]:
address = "W." + " " + pre.split()[-2].lstrip().replace(" ", " ").capitalize()
else:
address = pre.split()[-1].lstrip().replace(" ", " ").capitalize()
else:
address = "Unknown"
print(address + " | " + action)
def is_number(x):
if type(x) == str:
x = x.replace(',', '')
try:
float(x)
except:
return False
return True
def text2int(textnum, numwords={}):
units = [
'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',
'sixteen', 'seventeen', 'eighteen', 'nineteen',
]
tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
scales = ['hundred', 'thousand', 'million', 'billion', 'trillion']
ordinal_words = {'first': 1, 'second': 2, 'third': 3, 'fifth': 5, 'eighth': 8, 'ninth': 9, 'twelfth': 12}
ordinal_endings = [('ieth', 'y'), ('th', '')]
if not numwords:
numwords['and'] = (1, 0)
for idx, word in enumerate(units): numwords[word] = (1, idx)
for idx, word in enumerate(tens): numwords[word] = (1, idx * 10)
for idx, word in enumerate(scales): numwords[word] = (10 ** (idx * 3 or 2), 0)
textnum = textnum.replace('-', ' ')
current = result = 0
curstring = ''
onnumber = False
lastunit = False
lastscale = False
def is_numword(x):
if is_number(x):
return True
if word in numwords:
return True
return False
def from_numword(x):
if is_number(x):
scale = 0
increment = int(x.replace(',', ''))
return scale, increment
return numwords[x]
for word in textnum.split():
if word in ordinal_words:
scale, increment = (1, ordinal_words[word])
current = current * scale + increment
if scale > 100:
result += current
current = 0
onnumber = True
lastunit = False
lastscale = False
else:
for ending, replacement in ordinal_endings:
if word.endswith(ending):
word = "%s%s" % (word[:-len(ending)], replacement)
if (not is_numword(word)) or (word == 'and' and not lastscale):
if onnumber:
# Flush the current number we are building
curstring += repr(result + current) + " "
curstring += word + " "
result = current = 0
onnumber = False
lastunit = False
lastscale = False
else:
scale, increment = from_numword(word)
onnumber = True
if lastunit and (word not in scales):
# Assume this is part of a string of individual numbers to
# be flushed, such as a zipcode "one two three four five"
curstring += repr(result + current)
result = current = 0
if scale > 1:
current = max(1, current)
current = current * scale + increment
if scale > 100:
result += current
current = 0
lastscale = False
lastunit = False
if word in scales:
lastscale = True
elif word in units:
lastunit = True
if onnumber:
curstring += repr(result + current)
return curstring
Wow, that's way above my pay grade. I'm just trying to visualize the audio, hard of hearing, need to much volume for others in the house,In my experience so far, P25 Phase II quality is too poor for speech recognition. The best success I have had is with the automatic dispatching of fire calls. I use Microsoft Azure Cognitive Services with a custom trained model. The model consists of 300 wave files with text files transcripts. I also included a vocabulary of all call types and all street names in my city. I then run the output through about a hundred "find and replace" string operations to get an output that is about 95% correct.
That was my conclusion also. Thanks,I tried the online Microsoft 365 and dictate in Words, and I have only one VBcable from SDR# and used its DMR plugin and it was more than 95% accurate. It even translated automatically if it where some foreign word used.
It stops dictate as soon as I use another window or if it's silence for 30 sec so not really totally useful for scanner work.
It can go back several words and edit mistakes it have done so it seems to be highly intelligent. If it only could stay permanently enabled. Then I could have it write everything that's being said on a channel and I can read that when I return to my PC. Much easier than listening thru all the voice files.
/Ubbe