Skip to content

Commit

Permalink
updated to sdk 1.0.9, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
keighrim committed Jul 24, 2023
1 parent c05c37b commit 3fe5950
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 38 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git/
.github/
.gitignore
.dockerignore
Dockerfile
Containerfile
bin/
build/
*~
**/*.pyc
**/__pyche__
21 changes: 0 additions & 21 deletions .github/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/issue-apps-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types:
- opened
- transferred
pull_request:
pull_request_target:
types:
- opened

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
issues:
types:
- closed
pull_request:
pull_request_target:
types:
- closed

Expand Down
3 changes: 2 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the same base image version as the clams-python python library version
FROM ghcr.io/clamsproject/clams-python-ffmpeg:1.0.7
FROM ghcr.io/clamsproject/clams-python-ffmpeg:1.0.9
# See https://github.com/orgs/clamsproject/packages?tab=packages&q=clams-python for more base images
# IF you want to automatically publish this image to the clamsproject organization,
# 1. you should have generated this template without --no-github-actions flag
Expand All @@ -20,6 +20,7 @@ ENV CLAMS_APP_VERSION ${CLAMS_APP_VERSION}
################################################################################
RUN apt-get update
RUN pip install numpy
# numpy and gcc are required for installing aubio as sdist
RUN apt-get install -y pkg-config build-essential
RUN apt-get install -y \
libaubio-dev \
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ This app detects and returns timespans in the audio track of a (potentially mult

## User instruction

General user instruction for CLAMS apps is available at [CLAMS Apps documentation](https://apps.clams.ai/clamsapp). The general user template should cover the vast majority of use cases for this app, as all user configuration is done via runtime parameters.
General user instructions for CLAMS apps is available at [CLAMS Apps documentation](https://apps.clams.ai/clamsapp).

## System requirments

The `aubio` Python library which this app uses is built on top of the `ffmpeg` multimedia processing framework. A default `ffmpeg` installation should contain everything you need to run the app as a standalone service (e.g., lib-dev codecs).

## Configurable runtime parameters

Common use cases for altering the runtime parameters include:
Although all CLAMS apps are supposed to run as *stateless* HTTP servers, some apps can configured at request time using [URL query strings](https://en.wikipedia.org/wiki/Query_string). For runtime parameter supported by this app, please visit [CLAMS App Directory](https://apps.clams.ai) and look for the app name and version.

1. Limiting the duration of processed audio, in order to prevent superfluous processing. For example, if the tones are known to be in the first 30 seconds of the video.
Specifically for this app, common use cases for altering the runtime parameters include:

2. Altering the length threshold of tones, in order to capture shorter lengths of monotonic audio.
1. `stopAt`: Limiting the duration of processed audio, in order to prevent superfluous processing. For example, if the tones are known to be in the first 30 seconds of the video.
2. `tolerance`: Altering the length threshold of tones, in order to capture shorter lengths of monotonic audio.
16 changes: 9 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Imports =====================================================================|
import argparse
import logging
from typing import Union
from clams import ClamsApp, Restifier
from mmif import Mmif, AnnotationTypes, DocumentTypes
Expand Down Expand Up @@ -27,7 +28,8 @@ def _annotate(self, mmif: Union[str, dict, Mmif], **parameters) -> Mmif:
conf = self.get_configuration(**parameters)

newview = mmif_obj.new_view()
self.sign_view(newview, conf)
# we want to sign the view with the raw user input, not the processed one
self.sign_view(newview, parameters)

for file, location in files.items():
newview.new_contain(AnnotationTypes.TimeFrame,
Expand Down Expand Up @@ -98,21 +100,21 @@ def _detect_tones(filepath, **kwargs):

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--port", action="store", default="5000", help="set port to listen"
)
parser.add_argument("--port", action="store", default="5000", help="set port to listen" )
parser.add_argument("--production", action="store_true", help="run gunicorn server")
# more arguments as needed
# add more arguments as needed
# parser.add_argument(more_arg...)

parsed_args = parser.parse_args()

# create the app instance
app = TonesDetector()

http_app = Restifier(app, port=int(parsed_args.port)
)
http_app = Restifier(app, port=int(parsed_args.port))
# for running the application in production mode
if parsed_args.production:
http_app.serve_production()
# development mode
else:
app.logger.setLevel(logging.DEBUG)
http_app.run()
3 changes: 1 addition & 2 deletions metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def appmetadata() -> AppMetadata:
metadata.add_parameter(name='timeUnit',
description='the unit for annotation output',
type='string',
choices=['seconds','milliseconds'],
choices=['seconds', 'seconds', 'milliseconds'],
default='seconds',
multivalued=False)

Expand Down Expand Up @@ -71,4 +71,3 @@ def appmetadata() -> AppMetadata:
for param in ClamsApp.universal_parameters:
metadata.add_parameter(**param)
sys.stdout.write(metadata.jsonify(pretty=True))

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
clams-python==1.0.9
aubio>=0.4.9
clams-python==1.0.7
ffmpeg>=1.4
ffmpeg-python>=0.2.0
numpy>=1.24.2

0 comments on commit 3fe5950

Please sign in to comment.