Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asr-benchmarks
Manage
Activity
Members
Labels
Plan
Issues
8
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcin Wątroba
asr-benchmarks
Commits
9cda9759
Unverified
Commit
9cda9759
authored
3 years ago
by
Marcin Wątroba
Browse files
Options
Downloads
Patches
Plain Diff
Add Base service improvement
parent
30a40ace
Branches
Branches containing commit
1 merge request
!10
Feature/add auth asr service
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sziszapangma/integration/asr_processor.py
+7
-3
7 additions, 3 deletions
sziszapangma/integration/asr_processor.py
sziszapangma/integration/base_asr_service/asr_processor.py
+4
-0
4 additions, 0 deletions
sziszapangma/integration/base_asr_service/asr_processor.py
with
11 additions
and
3 deletions
sziszapangma/integration/asr_processor.py
+
7
−
3
View file @
9cda9759
from
abc
import
ABC
,
abstractmethod
from
abc
import
ABC
,
abstractmethod
from
typing
import
Any
,
Dict
from
typing
import
Any
,
Dict
,
Optional
import
requests
import
requests
...
@@ -16,14 +16,18 @@ class AsrProcessor(ABC):
...
@@ -16,14 +16,18 @@ class AsrProcessor(ABC):
class
AsrWebClient
(
AsrProcessor
):
class
AsrWebClient
(
AsrProcessor
):
_url
:
str
_url
:
str
_auth_token
:
Optional
[
str
]
def
__init__
(
self
,
url
:
str
):
def
__init__
(
self
,
url
:
str
,
auth_token
:
Optional
[
str
]
):
super
(
AsrWebClient
,
self
).
__init__
()
super
(
AsrWebClient
,
self
).
__init__
()
self
.
_url
=
url
self
.
_url
=
url
self
.
_auth_token
=
auth_token
def
call_recognise
(
self
,
file_path
:
str
)
->
Dict
[
str
,
Any
]:
def
call_recognise
(
self
,
file_path
:
str
)
->
Dict
[
str
,
Any
]:
files
=
{
"
file
"
:
open
(
file_path
,
"
rb
"
)}
files
=
{
"
file
"
:
open
(
file_path
,
"
rb
"
)}
res
=
requests
.
post
(
self
.
_url
,
files
=
files
)
headers
=
dict
({
'
Authorization
'
:
f
'
Bearer
{
self
.
_auth_token
}
'
})
\
if
self
.
_auth_token
is
not
None
else
dict
()
res
=
requests
.
post
(
self
.
_url
,
files
=
files
,
headers
=
headers
)
json_response
=
res
.
json
()
json_response
=
res
.
json
()
print
(
json_response
)
print
(
json_response
)
return
json_response
return
json_response
This diff is collapsed.
Click to expand it.
sziszapangma/integration/base_asr_service/asr_processor.py
+
4
−
0
View file @
9cda9759
...
@@ -48,10 +48,14 @@ class AsrProcessor(ABC):
...
@@ -48,10 +48,14 @@ class AsrProcessor(ABC):
else
:
else
:
return
None
return
None
def
health_check
(
self
)
->
Response
:
return
jsonify
({
'
status
'
:
'
running
'
})
def
start_processor
(
self
):
def
start_processor
(
self
):
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
auth
=
HTTPTokenAuth
(
scheme
=
"
Bearer
"
)
auth
=
HTTPTokenAuth
(
scheme
=
"
Bearer
"
)
auth
.
verify_token
(
self
.
is_token_correct
)
auth
.
verify_token
(
self
.
is_token_correct
)
Path
(
_TEMP_DIRECTORY
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
Path
(
_TEMP_DIRECTORY
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
app
.
route
(
"
/process_asr
"
,
methods
=
[
"
POST
"
])(
auth
.
login_required
(
self
.
process_request
))
app
.
route
(
"
/process_asr
"
,
methods
=
[
"
POST
"
])(
auth
.
login_required
(
self
.
process_request
))
app
.
route
(
"
/health_check
"
,
methods
=
[
"
GET
"
])(
self
.
health_check
)
app
.
run
(
debug
=
True
,
host
=
"
0.0.0.0
"
)
app
.
run
(
debug
=
True
,
host
=
"
0.0.0.0
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment