ModelAudioTransformStream opens the bidirectional AudioTransformStream RPC and returns the underlying stream client. The caller is responsible for sending the initial Config message, subsequent Frame messages, and for calling CloseSend when input is done. The returned stream's Recv reports EOF when
( ctx context.Context, loader *model.ModelLoader, appConfig *config.ApplicationConfig, modelConfig config.ModelConfig, )
| 136 | // calling CloseSend when input is done. The returned stream's Recv reports |
| 137 | // EOF when the backend has finished emitting frames. |
| 138 | func ModelAudioTransformStream( |
| 139 | ctx context.Context, |
| 140 | loader *model.ModelLoader, |
| 141 | appConfig *config.ApplicationConfig, |
| 142 | modelConfig config.ModelConfig, |
| 143 | ) (grpc.AudioTransformStreamClient, error) { |
| 144 | mopts := ModelOptions(modelConfig, appConfig) |
| 145 | transformModel, err := loader.Load(mopts...) |
| 146 | if err != nil { |
| 147 | recordModelLoadFailure(appConfig, modelConfig.Name, modelConfig.Backend, err, nil) |
| 148 | return nil, err |
| 149 | } |
| 150 | if transformModel == nil { |
| 151 | return nil, fmt.Errorf("could not load audio-transform model %q", modelConfig.Model) |
| 152 | } |
| 153 | return transformModel.AudioTransformStream(ctx) |
| 154 | } |
| 155 | |
| 156 | // persistAudioInput copies a transient input file (typically a multipart |
| 157 | // upload that lives in an os.TempDir slated for cleanup) into the long-lived |
no test coverage detected