Skip to content

Commit

Permalink
Enhance GitHub Actions build plugin: update Bazel build commands for …
Browse files Browse the repository at this point in the history
…gRPC and Protobuf, improve compiler warning settings for ObjC, and add error handling in audio processing
  • Loading branch information
royshil committed Nov 28, 2024
1 parent 24e3a14 commit 583ed86
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
5 changes: 2 additions & 3 deletions .github/actions/build-plugin/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ runs:
git clone https://github.com/grpc/grpc.git --depth 1
cd grpc
git submodule update --init
bazel build --compilation_mode=opt --build_tag_filters="-protos" \
@com_google_protobuf//:protoc @com_github_grpc_grpc//src/compiler:grpc_cpp_plugin
bazel build --compilation_mode=opt @com_github_grpc_grpc//:grpc++ @com_google_protobuf//:protoc @com_github_grpc_grpc//src/compiler:grpc_cpp_plugin
echo "PROTOC_EXECUTABLE=$(realpath $(bazel cquery --output=files @com_google_protobuf//:protoc 2>/dev/null | grep "opt.*protoc$"))" >> $GITHUB_ENV
echo "PROTOC_EXECUTABLE=$(realpath $(bazel cquery --output=files @com_google_protobuf//:protoc 2>/dev/null | grep "protoc$" | sed 's/fastbuild/opt/g'))" >> $GITHUB_ENV
echo "GRPC_PLUGIN_EXECUTABLE=$(realpath $(bazel cquery --output=files @com_github_grpc_grpc//src/compiler:grpc_cpp_plugin 2>/dev/null | sed 's/fastbuild/opt/g'))" >> $GITHUB_ENV
echo "GRPC_INCLUDE_DIR=$(realpath $(pwd)/include)" >> $GITHUB_ENV
Expand Down
10 changes: 9 additions & 1 deletion cmake/macos/compilerconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ else()
# clang options for ObjC
set(_obs_clang_objc_options
# cmake-format: sortable
-Werror=block-capture-autoreleasing -Wno-selector -Wno-strict-selector-match -Wnon-virtual-dtor -Wprotocol
-Werror=block-capture-autoreleasing
-Wno-selector
-Wno-strict-selector-match
-Wno-unused-function
-Wno-unused-parameter
-Wno-unused-private-field
-Wno-unused-variable
-Wnon-virtual-dtor
-Wprotocol
-Wundeclared-selector)

# clang options for ObjC++
Expand Down
2 changes: 1 addition & 1 deletion src/cloud-providers/clova/clova-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class ClovaProvider : public CloudProvider {

protected:
virtual void sendAudioBufferToTranscription(const std::deque<float> &audio_buffer) override;
};
};
30 changes: 22 additions & 8 deletions src/cloudvocal-processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <obs.h>

#include <vector>
#include "plugin-support.h"

int get_data_from_buf_and_resample(cloudvocal_data *gf, uint64_t &start_timestamp_offset_ns,
uint64_t &end_timestamp_offset_ns)
Expand All @@ -23,7 +24,7 @@ int get_data_from_buf_and_resample(cloudvocal_data *gf, uint64_t &start_timestam
return 1;
}

#ifdef LOCALVOCAL_EXTRA_VERBOSE
#ifdef CLOUDVOCAL_EXTRA_VERBOSE
obs_log(gf->log_level,
"segmentation: currently %lu bytes in the audio input buffer",
gf->input_buffers[0].size);
Expand Down Expand Up @@ -75,27 +76,40 @@ int get_data_from_buf_and_resample(cloudvocal_data *gf, uint64_t &start_timestam
}
}

#ifdef LOCALVOCAL_EXTRA_VERBOSE
#ifdef CLOUDVOCAL_EXTRA_VERBOSE
obs_log(gf->log_level, "found %d frames from info buffer.", num_frames_from_infos);
#endif
gf->last_num_frames = num_frames_from_infos;

if (num_frames_from_infos <= 0 || copy_buffers[0].empty()) {
obs_log(LOG_ERROR, "No audio data found in the input buffer");
return 1;
}

if (gf->resampler == nullptr) {
obs_log(LOG_ERROR, "Resampler is not initialized");
return 1;
}

{
// resample to 16kHz
float *resampled_16khz[8];
uint32_t resampled_16khz_frames;
uint64_t ts_offset;
{
audio_resampler_resample(gf->resampler, (uint8_t **)resampled_16khz,
&resampled_16khz_frames, &ts_offset,
(const uint8_t **)copy_buffers[0].data(),
(uint32_t)num_frames_from_infos);
bool success = audio_resampler_resample(gf->resampler, (uint8_t **)resampled_16khz,
&resampled_16khz_frames, &ts_offset,
(const uint8_t **)copy_buffers[0].data(),
(uint32_t)num_frames_from_infos);

if (!success) {
obs_log(LOG_ERROR, "Failed to resample audio data");
return 1;
}

// push back resampled data to resampled buffer
gf->resampled_buffer.insert(gf->resampled_buffer.end(), resampled_16khz[0],
resampled_16khz[0] + resampled_16khz_frames);
#ifdef LOCALVOCAL_EXTRA_VERBOSE
#ifdef CLOUDVOCAL_EXTRA_VERBOSE
obs_log(gf->log_level,
"resampled: %d channels, %d frames, %f ms, current size: %lu bytes",
(int)gf->channels, (int)resampled_16khz_frames,
Expand Down

0 comments on commit 583ed86

Please sign in to comment.