Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rp_server_one
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ranasinghe R.A.P.T
rp_server_one
Commits
de3dca22
Commit
de3dca22
authored
Apr 14, 2022
by
Pamal-Ranasinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement voice extraction completed
parent
d0274b85
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
assets/converted_wav/converted.wav
assets/converted_wav/converted.wav
+0
-0
assets/sample_video.mov
assets/sample_video.mov
+0
-0
resources/__pycache__/speechExtraction.cpython-38.pyc
resources/__pycache__/speechExtraction.cpython-38.pyc
+0
-0
resources/speechExtraction.py
resources/speechExtraction.py
+31
-2
No files found.
assets/converted_wav/converted.wav
0 → 100644
View file @
de3dca22
File added
assets/sample_video.mov
0 → 100644
View file @
de3dca22
File added
resources/__pycache__/speechExtraction.cpython-38.pyc
View file @
de3dca22
No preview for this file type
resources/speechExtraction.py
View file @
de3dca22
from
flask_restful
import
Resource
from
loguru
import
logger
import
speech_recognition
as
sr
import
moviepy.editor
as
mp
import
json
class
SpeechExtraction
(
Resource
):
#Test function
# This function uses for extract the speech from a video
# params: self
# return: json
# author: Pamal Ranasinghe
def
get
(
self
):
return
'API is working'
\ No newline at end of file
try
:
# Check the endpoint execution
logger
.
info
(
"Speech Extraction - GET - hits"
)
clip
=
mp
.
VideoFileClip
(
r"assets/sample_video.mov"
)
clip
.
audio
.
write_audiofile
(
r"assets/converted_wav/converted.wav"
)
r
=
sr
.
Recognizer
()
audio
=
sr
.
AudioFile
(
"assets/converted_wav/converted.wav"
)
with
audio
as
source
:
audio_file
=
r
.
record
(
source
)
result
=
r
.
recognize_google
(
audio_file
)
# Create a dict object which includes the result
value
=
{
"text"
:
result
}
#return the json object which is having converted speech
return
json
.
loads
(
json
.
dumps
(
value
)),
200
except
Exception
as
e
:
logger
.
error
(
str
(
e
))
return
json
.
loads
(
json
.
dumps
({
"message"
:
"Something went wrong"
}))
,
500
\ No newline at end of file
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