Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-066
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
2022-066
2022-066
Commits
8cfd2b2d
Commit
8cfd2b2d
authored
Nov 14, 2022
by
De Silva K.C.C.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Text gen implementation
parent
1758ad91
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
Indexing/text_gen.py
Indexing/text_gen.py
+58
-0
No files found.
Indexing/text_gen.py
0 → 100644
View file @
8cfd2b2d
import
speech_recognition
as
sr
import
subprocess
import
os
import
sys
PYTHONIOENCODING
=
"UTF-8"
FOLDER_AUDIO
=
"audio_input"
FOLDER_TEXT
=
"text_output"
LANGUAGE
=
"en-US"
# print("starting...")
#
# if not os.path.isdir(FOLDER_AUDIO):
# os.mkdir(FOLDER_AUDIO)
#
# if not os.path.isdir(FOLDER_TEXT):
# os.mkdir(FOLDER_TEXT)
#
# paths = [os.path.join(FOLDER_AUDIO, nome) for nome in os.listdir(FOLDER_AUDIO)]
# files = [arq for arq in paths if os.path.isfile(arq)]
# wav_files = [arq for arq in files if arq.lower().endswith(".wav")]
#
# for filename in wav_files:
# r = sr.Recognizer()
# with sr.AudioFile(filename) as source:
# audio = r.record(source)
#
# command = r.recognize_google(audio, language='en-IN', show_all=True)
# print(command)
#
# print("running file {}".format(filename))
#
# filefinal = filename.split("audio_input/")[1].split(".wav")[0]
# filefinal = '{}/{}.txt'.format(FOLDER_TEXT, filefinal)
# with open(filefinal, 'w') as arq:
# arq.write(str(command))
#
# print("create a new file {}".format(filefinal))
#
# print("finish")
def
convert_audio_to_text
(
filename
):
r
=
sr
.
Recognizer
()
with
sr
.
AudioFile
(
filename
)
as
source
:
audio
=
r
.
record
(
source
)
try
:
command
=
r
.
recognize_google
(
audio
,
language
=
'en-IN'
,
show_all
=
True
)
print
(
command
[
"alternative"
][
0
][
"transcript"
])
return
command
[
"alternative"
][
0
][
"transcript"
]
except
:
return
'did not convert'
# convert_audio_to_text('audio_input/3.wav')
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment